instruction
stringlengths
34
36.1k
I'm going to describe the situation first and ask questions in the end. I need to validate a scalar value using the Symfony Validator component. The value is an associative array. Now I have defined the following validation constraints according to the expected structure: new Constraints\Collection([ 'Call'...
I ran into the situation where I have to decide whether a property belongs to my aggregate or not. My domain logic is the following. A User has a group in his organization ex: IT, SALES, MARKETING. Depending on which group this user belongs to, he will have a set of Permissions. The logic of which group has which permi...
I am reading Vaughn Vernon's series of articles about effective aggregate design. On the subject of deciding between transactional vs eventual consistency, it states the following: Discussing this with Eric Evans revealed a very simple and sound guideline. When examining the use case (or story), ask whether it's t...
Do we get efficiency in terms of load handling when the same container (in this case the container has a apache server and a php application) is deployed 5 or more times (i.e. 5 or more containers are deployed) on the same Host or VM? Here efficiency would mean whether the application is such architecture is able to se...
Problem: A single client of our system can completely flood all available resources with a massive workload. You can consider we have only one queue, and anyone can schedule any amount of work in it. Any other client that subsequently submits a small amount of work will have to wait until the first tasks have been full...
The gist of my problem is that I'm trying to make a basic simulation for periodically collected data. More specifically, given the position of a radio antenna, the RF patterns would be simulated using the Python library Pylayers, where the finished model is constructed in matplotlib for viewing. I want this to be done...
How keys should be designed in a Key-Value Store? For example if there is a need for querying users based on their emails (a manual secondary index), should the key be user:email_index:user@domain.com or user:email_index:<SOME_FIXED_WIDTH_HASH>? If so, what hash algorithm should be used? Is there a sequential hash algo...
I really liked the concepts in the video The Principles of Clean Architecture by Uncle Bob Martin. But I feel like this pattern is like a combination of Abstract Factory and Builder patterns at its core. This is one way to write good programs but not the only way. Rails and React are 2 frameworks that come to mind that...
I'm not sure how to correctly describe my problem... Ever since I started learning how to program, I recognized that many more experienced programmers have very strict (and, in the POV of a beginner, completely artificial) rules how should programs be written. These rules seem simplicistic, yet are followed with an alm...
I am now working on a project that started as university homework and actually, still is a university homework (not turned in yet...) and, if I'm successfull (that doesn't mean turning it in and getting a better-than-failing grade, that means bringing it to publication quality), this is going to be the largest piece of...
Our system generally processes in two services which are run under IIS. Service A gets HTTP requests, parses the content, and shoots it to RabbitMQ. Service B takes messages from RabbitMQ, parses them further, and writes them to a database. IIS can detect when it should spin up more worker processes for Service A, beca...
I've a project where the users will be able to tags themselves with skills tags (maybe predefined in the system) , and then the project managers on a company would be able to search the best user with a set of skills for a given task. For example : Java would be a tag, or maybe Android , etc. I'll use a relational DB....
More specifically, with regards to ATDD (sort of BDD flavored, or some could argue what was actually intended in the first place by TDD) should be there much UI testing? As I have been testing my UI components on my flavor of the month client-side MCV framework I find that I haven't really been testing much in the comp...
My understanding of this is that object pools are useful when we want to work with an object but we want to use one that's already been instantiated. It's like a library book - you check out a book and you return it when you're finished reading it. However, I struggle to see how this design pattern is used in real life...
In my app two components A and B, have their data and state based on the data and state of a 3rd component, component C: Both A and B can change the data of component C. Both A and B listen to changing of data of component C and react to it by re-computing their internal data and state. A and B each run on their own ...
When creating single page apps that communicate with a backend API via ajax, what is common (best?) practice regarding updating different server side database objects as a result of one client side action? For example let's say I delete something on the client which in turn results in needing to update several other it...
In my new SPA (Single Page Application), I have teachers, which can make tests, and students, which can take tests, subscribe to teachers, and view their grades. This means that in JavaScript, they will both have very different actions they can do. But the HTML and CSS, incidentally, are very similar. My goal is to mak...
I've recently seem event storming as a quite reasonable way to get understanding form a domain, in order to build a domain model. We understand the events in the domain, which for the domain experts ends up boiling down to just telling the business processes they are used to in their everyday life, then we find out the...
I have generated the program graph of a method that contains an if condition and a for loop, and I need to generate test cases that covers "every branch". Would this include the for loop, given that program graphs are abstractions of the actual code, and the for loop does cause there to be two separate paths in the pro...
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...