instruction stringlengths 34 36.1k |
|---|
Given a requirement like
if A and B and not C then D must happen within 10ms
That can clearly be tested albeit at the cost of some pain proving the 10ms bit, but what happens if the requirement was instead
if and only if A and B and not C then D.....
It seems to me that the only if likely requires an exhaustive ex... |
I have 3 projects in my solution :
An ASP MVC project
A console app project
A class library project (the DataAccessLayer)
I didn't want to recreate an ADO.net entity data model for each project so I've "simply" created a new class library project and added the ADO.net entity data model inside it. Is it an usual way t... |
I've recently started a C# programming job, but I've got quite a bit of background in Haskell.
But I understand C# is an object-orientated language, I don't want to force a round peg into a square hole.
I read the article Exception Throwing from Microsoft which states:
DO NOT return error codes.
But being used to Ha... |
We are designing a web API to transfer objects obtained from a database to a client application which is a front end GUI. The server side business logic will be implemented (for better or worse) in stored procs.
To minimize the size of transferred objects, integer ids will sent in the case that an object references ano... |
I'm currently working on my graduation for my "Software Development" studies, in which I have to develop complex software individually in an external company. This all needs to be done in a structured manner, creating all corresponding documents.
For this project I have chosen to work with the IEEE standard documents: ... |
I wrote a Java API that accepts ClassLoaders as parameter, even though it won't accept any ClassLoader that isn't a URLClassLoader (because I'm only interested in the URLClassLoader::getURLs() method):
/**
* @throws NullPointerException if classLoader is null.
* @throws IllegalArgumentException if classLoader is not ... |
I understand "devops" to be the application of the development processes (issue tracking, version control, release management...) to operations tasks (deployment, migration...).
Is there an equivalent term for the application of development processes to QA tasks (testing that only a human can perform, rather than autom... |
Using C++, often I hear that you should avoid throwing exceptions for flow control and you should avoid calling functions in conditions where you know they will throw. For example, if a function throws when you pass it an empty string, why not check for empty before calling that function?
I personally as of late have b... |
Currently we have the following branches:
Develop
Release 1
Release 2
etc..
Master
When we want to cut off new features for a release, we create a new release branch (say release 3). We then only apply bug fixes etc. to the release branch and no more major changes.
When release 3 has been tested and everything is... |
In some code bases (such as hydra, and thrust's tuple implementation) I see namespaces defined entirely with macros. It appears the reason for this is so that you can configure the namespace to your liking. Is this the only use case for this practice? Even so why shouldn't all libraries define a macro for the namesp... |
I was reading these pages (1,2,3), but I'm still unsure if this violates the guideline.
I have the following data being read from a website:
Date: July 13, 2018
Type: Partial Solar Eclipse
Location: South in Australia, Pacific, Indian Ocean
Date: July 27, 2018
Type: Total Lunar Eclipse
Location: Much of Europe, Much... |
In a video about software architecture that I'm watching, it's stated that the main program/subroutine architectural style
promotes modularity and function reuse
Code reuse is one of the main benefits I've always heard object oriented programming offers. This answer to a related question says the same:
Code re-use i... |
I have a java program, I want to insert data into oracle db and solr at the same time. How can I make sure that data in the db and solr are consistent?
|
I was looking into PyQt5 for one of my side-projects and would really like to get to learn it better. However, I wasn't sure how to correctly format the code. I've seen tutorials do class definitions for a main window and some do basic function definitions.
Which of these options tends to be favored and what does code ... |
I have several web applications. All of them have config files. I'm trying to figure out when it's appropriate to store data in a config file and when in database in json or free format? For instance, I have setting for several payment methods: PayPal, Stripe, etc. All of them have different sets of settings, some requ... |
I have a validation method like this
def validate(a, b, c, d, e, f): Boolean = {
val rs1 = check1(a, b)
val rs2 = check2(c, d)
val rs3 = check3(e, f)
rs1 && rs2 && rs3
}
I have tests for all of the smaller methods check1, check2, and check3 and I want to test the big method validate also. But to test it, I im... |
What are best practices for cleaner code style when accessing nested members on higher abstraction levels.
class A{
B b;
void Do(){b.c.d.e.f.g.value;}
}
class B{public C c;}
class C{public D d;}
class D{public E e;}
class E{public f f;}
class F{public g g;}
class G{public int value;}
|
I've been using UML 2.x for several years and it really worked for Object-Oriented languages like C# and Java especially when the software was big enough to be considered an enterprise-level system.
Now I'm working on different systems with different paradigms and considerations, mostly using Python. The team isn't tha... |
My question sounds a bit dumb.
Usually we are suggested to use existing libraries or frameworks, to avoid reinventing the wheel, or to achieve some "good practices" (e.g. during software distribution).
I'm facing situations in which the library/framework size is way larger than the "executable code". For example, when ... |
I am trying to figure out a way to solve the following dependency problem.
I have a parent object DomManager that has the responsibility to handle all the interaction with the DOM. It initializes several modules and two of them are dependent of each other: PlayerDom and Sticky.
At a certain point, a PlayerDom's method... |
"Premature optimization is the root of all evil"
I think this we can all agree upon. And I try very hard to avoid doing that.
But recently I have been wondering about the practice of passing parameters by const Reference instead of by Value. I have been taught / learned that non-trivial function arguments (i.e. most n... |
I have a long running process that collects together the IDs of Aggregates that have been edited/changed, so that a later command can 'publish' them to a legacy model.
I understand that I should use a kind of Saga for this which listens to certain events, then stores additional IDs for later processing.
The question I ... |
Apart of the code conventions to use camelCase, PascalCase etc., are there any conventions for naming packages and classes in Java?
For example, I have an mvc project and the main package is com.myproject. In this package I have:
com.myproject.model
com.myproject.view
com.myproject.controller.
Is there any conven... |
I asked this question a while ago: What is the "best" way to apprach validation from the perspective of a DDD purist?
At the time I decided to put the validation logic inside the domain object constructor like one of the answerers suggested.
The business have recently become interested in how data has arrived at its cu... |
Is it better REST API design to use conditionally required fields or to create different resources based on the controlling field's value? Here's an example:
POST route/automobile
{
"type": "car", //This field controls validation rules
"bedLength": 6, //required if type == "truck"
"trunkVolume": 10 //required if type =... |
When reading about when to make a method static or not, I've seen a general principle, as summarized by this post, that a method should only be static if it does not modify a state and its result depends only on the parameters provided to it. However, the most highly voted answer in this post states that static methods... |
Suppose my server PHP end point follows something along the lines of the following:
Client sends request to server.
Server updates a record
Server might do some PHP processing...
Server updates record again
What to do if the server crashes whilst performing either of the SQL commands (either 2 or 4) or during 3.
Is i... |
I was having a good read on Eric Lippert's blog about Wizard and Warriors.
It suggests the creation of a Rules class, quote:
We keep on talking about “rules”, and so apparently the business
domain of this program includes something called a “rule”, and those
rules interact with all the other objects in the busine... |
We are working on a project which interacts with multiple third party systems and they need each other's data to function. Now, for some data which needs to be in sync in multiple systems, we are planning to introduce event based architecture where if the data is created/updated in one system, it will publish an event ... |
In Redux (React Flux implementation) guide https://redux.js.org/basics/reducers it is said, that
In Redux, all the application state is stored as a single object
My questions are:
How seriously we should take this principle? E.g. my application can have multiple entities like Person, Invoice+InvoiceLine, Article, et... |
If I want to test frontend code (e.g. react SPA) that queries the backend and I stub out the responses from the backend using sinon fake server/fake XHR, then what happens if the backend code changes?
If the backend changes then the frontend tests will continue to pass, but the functionality may well be broken. It is p... |
Let's say I have an application that maintains relationships between objects - think of a parent-child relationship tree. The lineage of these objects are critical, so maintaining references from Object A <-> Object B <-> Object C is very important. I cannot let the GC clean up any of these objects. Access to the data ... |
I am doing a bit of research on hash functions. I understand the concept that it is an equation that is easy to do one way (you take the number 00011010 for example and do reasonably simple math with it) but the function you use is very difficult to do the other way. I cannot however find any examples of what a one-way... |
I am trying to implement an ISO standard which by summary has the following:
There are operations (like an action in MVC)
There are respective request and response per operation
These requests and responses have corresponding XSD's
These XSD's are changing per year (as per my observation)
Here are my challenges for n... |
While writing Integration tests for spring applications, I tend to come across checks for different Multilevel Data Objects For Eg:
AssertNotNull("Node 10 is null", getNode1().getNode8().getNode10().getNode7());
This assertions works well provided that Objects A -> B -> C are not null, otherwise if any one of these ... |
I have recently started a course in software development and I'm having some confusion over modelling my system in a Class Diagram. The context of the system is as follows:
The user wants to calculate the performance (power consumption and outlet temperature) of an air conditioner unit at a particular inlet temperature... |
I'm working on my first P2P app using C# core and gRPC and I'm finding it difficult to understand the concepts of how nodes find each other and build a routing table.
For my design I'd like to only have nodes and no listener/directory/discovery servers.
I'll have a list of a few "known nodes" that can start off the cha... |
I created a new application and I am thinking where is the best place to generate a UUID.
Generate a UUID in application level and persist it
Generate a UUID in Database level
I have a feeling that is a better approach to generate the UUID in Database level.
What do you think and why?
Many thanks in advance
|
In SWEBOK version 3, there are separate processes defined for requirements and design: "Software Requirements" and "Software Design." Under "Software Requirements" there is a section called "Software Requirements Specification."
Since defining fields of the different object of a new model (e.g. set of classes) is such ... |
We use GIT to maintain an open source code(GPLV2) for our Application. Sometimes we need to introduce patch from community when find bugs.
I wonder to know:
Can we modify the author when commit patch to our GIT repositories? We want to keep upstream info (author, URL, and patch's log) in commit info.
Do we need to dis... |
If I'm faced with the decision to write clean, beautiful code, but I'd be opening up a new path bugs could take to appear, should I take it? (Provided I'm not willing to spend the time to come up with a way that satisfies both.)
To elaborate: I'm writing a Pong game as practice, and I could either write the exactly sam... |
I'm struggling in how to represent and reuse some "operations" that are commonly done by the Applications Services but aren't part of the Domain. A bit of context:
I implement CQRS for the Application Services and follow this structure (Example):
/Services
/Client (FunctionalModule)
/Commands
/C... |
When do we need to subclass a Singleton class or in other words, is it good to subclassing a Singleton?
If its generally allowed what would be the pros and cons and how to handle or get instance from sub class?
It would be nice if you can give some examples snippets in java. Doesnt it break the single responsibility pr... |
I recently came across an old webapp project which is using a repository layer between domain and persistence layer. However, the repository layer has been used weirdly.
One example is the blog section where posts and comments are persisted. A Post has many Comments.
public class Post {
//..
private List<Commen... |
I must create a basic calendar of one year. I thought to use a generic Tree with the year like root, months as children of root, days as children of months etc...
Is it the right way?
I receive data of calendar from a library calendar of Python. For some days, or hours I must associate some events and I must represent ... |
There is a discussion at work about the correct use of interfaces in OOP. I have been taught, and always worked from the premise, that interfaces precede concretions and all methods should be dealing in contracts. This is decoupling 101 to me.
I have found that applying this pattern universally teaches junior devs the ... |
I have an entity that has a dollar balance property. Whenever an event occurs that causes the balance to change, such as a debit, within the same transaction the balance should be decremented by the amount of the debit (as a sort of "summary" value, so that a DB query won't need to be performed to retrieve the balance ... |
According to Should we avoid language features that C++ has but Java doesn't?, I know it is horrible to write C++ as if Java, mostly because it drops the beneficial features of C++ languages.
But responding to the point 2 in this question:
C++ code with C++ specific features (e.g.: friend functions, multiple inherit... |
I have 2 models, DTOs and database models (entities) that map to the database.
I usually put XML comments above the properties to describe what are they for.
class MyEntity
{
/// <summary>
/// Some summary
/// </summary>
public string SomeThing { get; set; }
}
Should I put these comments in my DTOs or ... |
A teammate of mine wrote some code in the following way:
Class Foo implements Job {
// Framework uses type-hinting for dependency injection, only works on the handle() method
// not on other methods
public function handle(Dependency1 $dep1, Dependency2 $dep2) {
$this->setAlpha($dep1, $dep2);
$this->setBravo($d... |
I'm reading Two Scoops of Django 1.11. At 7th chapter it introduces "fat models". It says that best practice is to put a big part of logic into the model and keep views as thin as possible, but then it doesn't go deep into the argument. Assuming this way of thinking as django best practice and supposing models like the... |
I am working on a Xamarin application (Mvvm using Prism), I am also leveraging OData for communication between my backend and the mobile application.
The structure of my Mobile app is as follows:
View
View Model
Service Layer
OData Proxy to return Models
It is a little funky with OData because my domain/DTO models a... |
I have a hard time trying to find a 'rule of thumb' to follow when dictating certain responsibilities to either the API, or the client-side code base.
For instance, if I know a dataset should be returned in alphabetic order, should I as a front-end developer expect the data to be properly ordered alphabetically by the ... |
Every time I let Eclipse generate a field (most often a serial version UID), it adds a comment above it. Example:
/**
*
*/
private static final long serialVersionUID = 6347144762354188381L;
This happens because this behavior was for some reason deemed desirable by the developers of Eclipse. I know how to disable it... |
Many years ago, I posted a problem I had with some code and received a well written detailed answer that suggested the use of factory methods. I liked this approach, because I can provide a method name to let clients know
what was being created, and to prevent wrong parameters.
// Left out additonal parameters and va... |
(I am using Vuex but the question applies to any Flux architecture.)
I don't have a great understanding of the reasoning behind Flux architecture. I understand that it is nice to have all of the state in one place. I don't have a great understanding of other things though.
My question here is about where, exactly, the ... |
In my current work, we need to serialize some data and use it later.
Our data is in this format:
<resources>
<style name="Person">
<item name="name">name</item>
<item name="age">32</item>
</style>
<style name="Student" parent="Person">
<item name="course">course</item>
</style>
</resources>
We need to ... |
I'm working on client-server application. Client architecture (class hierarchy) looks like this:
System (name is of course different, more descriptive) - represents whole system
Module A - a class instance representing one module. One module = group of similar data and operations
User Module - another module
Users... |
I'm practicing unit testing (specifically Test-driven design or Red-Green-Refactor) while writing a recursive descent parser for a simple domain-specific language. In trying to unit test a method that takes in Tokens and Outputs a Syntax Tree, I've found that mocking the input is overly complex. I had thought my initia... |
I'm fairly new to object oriented programming and have a question I've stumbled upon regarding inheritance best practice.
I'm building a system for weapons in a game. I have a base class called Weapon and two subclasses – Melee and Projectile (such as knives and guns) – inheriting from Weapon.
All weapons have stats (... |
Given the following REST endpoints:
(GET, POST) /api/v2/employer
(GET) /api/v2/employer/{id}
(GET, POST) /api/v2/employer/{id}/employees
Should a consumer of this API have the ability to POST a new employer resource that includes a list of employees? For example:
POST: /api/v2/employer
{
employerName: "... |
I'm currently learning about event driven architecture and have the following 2 microservices.
Product Service - Responsible for managing products
Ordering Service - Responsible for processing orders
The Product Service publishes the following events whenever a product is created
ProductedCreatedEvent
ProductedUpda... |
I have a multi-tenant web application that allows authenticated users to make changes to their application instance - making comments as an example.
I'd like to build an API that allows a user of any external web app to be able to perform an action in my app and record the action as having been carried out by the logge... |
I have a large multi-module java/maven application where each child module is it's own java application and the root parent pom defines the standard dependencies
pom.xml - parent pom
- child1/pom.xml - app1
- child2/pom.xml - app2
I plan to write a custom maven plugin, which will be configured at sub-module level, whi... |
In C# if I want to split a string by another string I have to do something like that :
testString.Split(new string[] { "anotherString" }, StringSplitOptions.None);
From the overloaded String.Split MSDN Documentation we can see the implementation and why such a call has to be made.
Coming from Python, It is hard for me... |
I made a post in relation to this question on the SQA here but thought I would post on this board as it's more active.
I'm testing an underwriting engine with a front-end interface that asks a series of questions that either evaluate the input eligibility for a product, or prompt for further drill down questions which... |
This might be an easy question for experienced software engineers.
I'm currently reading the book Clean Architecture by Uncle Bob, and I'm trying to implement clean architecture in a Java project.
Now, in my project, I came across the exact same situation as described here in Chapter 17 of the book:
The red line is th... |
I wanted to ask a probably very simple question should a game engine be a dynamic link library (.dll) or a static library(.lib)?
Currently, I am doing the dynamic link route, this is influenced by the fact that there are a libraries that the engine includes and if I want to use the engine in a different project I have ... |
I understand that two way data binding can be expensive and slow. For example, imagine a toy grocery list app that lets you list grocery items and their prices, and shows you the sum of the prices (CodePen).
HTML
<div ng-app="app">
<div ng-controller="MainCtrl">
<table>
<thead>
<tr>
<t... |
I was reading about bruteforce login attack and one of the solution to prevent users from trying too many passwords in short amount of time is to add exponential delay for every failed login. But someone might do a DoS attack by keep trying to login with certain username.
I was thinking to do a window.location.reload()... |
I am looking into options for smoothing out our deliver and release pipeline, and would appreciate some advice on the best way to structure the source code.
This is a pretty large project, which consists of about 30 microservices. Microservices here is a very loose term, but for the sake of the question is it close eno... |
I am planning to build a live audience interaction webapp similar to Slido as practice/fun project.
User groups: admins and anonymous users
Admins:
login
create event (define event period and unique event code/name)
edit/delete user questions
highlight user questions (up to 3 questions per event)
Anonymous users:
jo... |
I have always wondered how sites like Blogger, Wordpress.com, Forumotion, Jcink or Forumatic (shut down) work but I can't seem to grasp an idea about how they're internally made.
At first sight they all work the same way, they allow users to create a new site (under their domain) using any popular software. Let's take ... |
I have done a lot of reading recently about Always Valid domain entities. I have come to believe that in order to ensure the entities are always valid I need to:
1) Remove primitive obsession and put validation/domain rules in the value object constructors as explained here: https://enterprisecraftsmanship.com/2016/09... |
I got the following code:
in the textbook that I am reading it says that for an infection to occur, mutation delta 1, it should be that the value of A must be different from the value of B. At this point I get lost, for what I know the infection condition in mutation testing appears when there is a change in the state... |
The question might sound a little weird, and I guess it is. I'm came up with the question while browsing through some design patterns. I came to the notorious state / strategy pattern and I came up with this code:
public class Account
{
public double Balance { get; private set; }
private IAccountState state;
... |
Is it theoretically possible to create a perfect compiler for a language (for example C) meaning that if two different persons make two different implementations of the same algorithm then the generated assembly (or machine) code is going to be the same in both cases?
I assume that both the programs give the same outpu... |
What are the options for installing an application which uses batch files, python, excel and proprietary software? I developed a command line shell to run fast, repeatable traffic simulations largely avoiding the GUI. Essentially a 3rd party program is installed by copying the files to a program directory (so windows d... |
I'm reading (just started) "Operating systems concepts" by Silberschatz, Galvin and Gagner and something called my attention when reading a basic primer on "timer" (1.5.2 on the book).
It says:
As long as the counter is positive, control
is returned to the user program. When the counter becomes negative, the
opera... |
I am developing a website to store books info such (title, book_no, author, edition, container...). I have two types of insert
insert series of books (Eg: harry porter series: chapter 1, 2,3...)
insert single book
I have created two table for this series and books, series table to store series info such (series_title... |
I have a Java application that needs to process some data. The data starts off in format A.
The application consists of a number of modules which are each capable of processing data. But not every module supports the same kind of data as in- and output. Module 1 accepts data in format A and outputs it in format B. Modu... |
Let me give a bit of background on the problem.
We have a java application which has MQ integration and an Integration Test pack which is also written in java.
The test pack runs all scenarios (positive and negative) by running the test cases (methods) and changing the parameters depending on the scenario. The way it d... |
My application follows repository pattern in the data access layer. However, I see, in repositories' data retrieval methods, column names and table name are hard-coded strings, which I think is not the right way since it is becoming a boilerplate code in many other methods too, with minor differences due to one or two ... |
Normally in java the RowMapper is placed in its own class.
Instead, what about this design, putting the RowMapper inside each domain object, and giving all of them a consistent name:
public class Address {
private String city;
public String getCity() {
return city;
}
public void setCity(Str... |
I am currently making an html-based editor, i know there are lots of editors out there especially html based but i want to do it myself once. What i am concerned about is, for e.g, when a user press a key, following operations will happen.
check if some text in the editor is already selected, if selected delete that t... |
The Iteration Planning Meeting (IPM) is equivalent to Sprint Planning. Before IPM, our team holds a Pre-IPM meeting which helps us avoid long IPM and get more details about the stories. This technique was suggested by one of our Agile consultants, but I couldn't find much info about Pre-IPM on the Internet.
What is the... |
So I just came across an extension method built into ASP.NET MVC: ChildActionExtensions.RenderAction(...). This invokes an action method using the given parameters and renders the result inline in the view.
This surprised me because I thought the MVC architecture had the controller setting up the model and passing it ... |
I'm struggling to understand the differences between an API such as a REST API and an ORM such as Entity Framework. I would also like to understand the benefits of each and in what situations either should be used.
It seems to me that they both act as a middle man and enable you to access and manipulate data from a dat... |
I'm putting together some ideas and personal conventions on how to configure state machines when using a language specific library.
Because I'm adding state machines to existing model classes in my project, some of the states I wish to leverage are distributed across their relations. State is not contained in a singul... |
My problem concerns two services: NotificationService(should be used by more than just the SurveyService), SurveyService.
I want to send recurring notifications to the user asking for participation in a survey. These should be sent in a certain interval until the max notification number is reached or until the user par... |
I need to design the feature like in encommerce(consider hotel booking site) we can enter the keyword/partial-keyword and need to return the relevant results.
For Example :- If site admin or hotel owner needs to add the below hotel details in system , It will be added in cache also(basically it will be write through ca... |
I was looking at this documentation.
https://laravel.com/docs/5.6/passport
it is quite long and I asked myself, why would one use this, over just a normal login where you store necessary information in the session?
E.g. when to use proper API, and when to just use web form login in a normal way?
|
I'm new to javascript environment (I have background in C++ physical simulations and game engines). With rise of HTML5 and WebGL I was thinking I'd like to try make some games/3D editors using javascript.
Problem is that larger project like game with 3D engine starts to be very messy. Instead of build system (makefile... |
When I think about the pros and cons of a static library folder and a package manager I feel like the library folder is a better approach.
Pros I see with a library folder:
No need for an external tool to manage packages.
No internet connection required to build.
Faster build (no package checking).
Simpler environment... |
I'm building web API. I have a problem where input differs from the output, for example, input expects just the id and output returns entire object.
Also, there are few things specific to the output that should never be sent in the input. For example, something that server calculates and returns it, but the client doe... |
In C if i declare
int x[4]
Which tells me its an integer array with each array element size fixed of size 4.
So after initialization when I access x[3] : address of array +element size which is 2 * index => (x[3]=2000+2*3) Assuming 2000 is the array address
In Javascript
We have
var a=[3,"rohan",6] //Dynamically type... |
Having a component that represents the database is wonderful! You can use it from the business logic to read and write data. But should that component be unit-tested?
I would argue that it should not. Unit-tests are all about testing the contract of a component with its external actors.
Let's take a typical interface ... |
C# 6 added auto-property initializers and so we can do
private List<LinearLayout> layouts1 { get; } = new List<LinearLayout>();
Is this better or worse than
private readonly List<LinearLayout> layouts2 = new List<LinearLayout>();
(N.B. this is related to the 2011 question .NET Properties - Use Private Set or ReadOnl... |
I've read answers to the following:
Why is Windows registry needed?
However I am curious about how this might apply to the practice of storing software license keys. I've seen developers store license information in the Windows registry, such as keys used to keep the software activated over a period of time (until the ... |
I'm struggling with the separation of logic between entities and interactors or Use Cases. If I design the entities with DDD principles, each entity would have methods corresponding to use cases, instead of setters and getters. In that case, I would case, I would have roughly a one-on-one mapping of interactor classes ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.