instruction
stringlengths
34
36.1k
I have a domain service and i need to create an aggregate inside it, because the logic for create this aggregate involves another aggregates and calls to repository to check some business rules. Is it correct to call Repository.Add(newEntity) inside a domain service? or a domain service only can query entities?
I have the following models. First, there is a Vector which has a circular DNA sequence. Second, there is a LinearizedVector which could one of below classes. LinearizedVectorBase: LinearizedVectorByOneCut ConcreteLinearizedVectorByOnePosition ConcreteLinearizedVectorByOneEnzyme ConcreteL...
I'm refactoring a health monitoring system which requires that certain attributes of an Entity have to be unique across the system. The attributes of an Entity are configurable by the end-user and the user can pick one or more attributes to be unique (either "universally" unique or unique across a geographical area). C...
The application that I am working on has numerous ...toMany relations, e.i. class Model can have several parameters. In Unidirectional world, it is simple to manage a collection. I can clean the collection (Java List/set) and add elements again, very inefficient but for DB performance, but doable. In a bidirectional w...
I hate PHP dollar signs. With that in mind I tried and found a way to access variables and function parameters without using them. First, to get value of a variable I used get_defined_vars: // echo $foo; echo get_defined_vars()['foo']; That was easy. To assign value to the variable I used extract: // $foo = 'Hello Wo...
I am creating software in MacOS that has over 10GB of assets associated with it. I can create a pkg that properly installs these but I have two problems. First, the notorization process required for Catalina is going into introduce a brutal bottleneck and weeks of debugging. Second, the distribution of this file is qui...
For example I have a static C++ array {'d', 'o', 'c', 's'}. And I have x86 architecture, with 32-bits length words. I want to replace letter c with g. As far as I understand, when we make a read operation from a byte addressable RAM, CPU always reads 1 word from it. So it will read the whole array. After CPU will read...
I'm trying to build a section of my app where two users can message each other. I've read about TCP and UDP and it seems like TCP is more suited due to ordered packet delivery. However, TCP requires a connection between the two users at all times for data to be sent but in my app one user may send another user a messag...
I am writing a HTTP client and am trying to decide what would be the correct time to wait before retrying the HTTP request in case the downstream service is for some reason not responding. I intend use a library which has a great feature for scheduling requests. It has a function called Schedule.exponential e.g. val e...
I'm building a multiplayer game where anyone can add its own server but there is only one central server that contains the database where player information, like experience and gold, are stored. To authenticate as a game server and thus have authorization to give gold to a player, you join a JWT, issued by me, to your...
At our company we have a monolith PHP application which has been broken down into multiple (self developed) packages around the (self developed) framework package. This application isn’t a SAAS solution, so the application is installed at the clients domain when developing their websites. For each package we have a str...
A bakery shop has to provide a stream of muffins for customers. The muffins are made by a baker in the kitchen and placed on a conveyor belt. The conveyor belt carries the muffins to where the customers are waiting to buy them. This scenario has been simulated using two processes: the baker and customer, and a shared ...
Suppose we want to develop a small module (time needed: two weeks of one developer). Then what about this new (maybe?) pipeline: The test engineer starts working: Think about all cases (including many edge cases) that we need to test. Write them down as code using an automated testing framework. At this stage, the ...
I have a problem in my app where I have many entities that can all reference each other in different ways. For example, I have a Job (e.g. build house) that I might assign to a team called "Plumbers" and a separate single user called "Bob". Jobs, Teams and Users are all entities with unique ids. When I make a request f...
I am working for a small electronics company and I was assigned a task of re-inventing and re-writing the software for our product delivery flow, which gathers design components, verifies them, and creates a delivery tarball which later gets send to the client. I am debating whether to choose Perl or Python for this. I...
So I've been an indie apps developer for 2 years (I launched my first Android app at the end of 2017), and I've built few apps since then, but all of them were simple apps. Currently I'm planning my next project, and in this next app the user will store sensitive data in the app (It'll be a Calendar App), and I'm plan...
Problem A streaming application should perform matching transitively i.e. if A == B & B == C then A == C Current Implementation Application accepts domain objects in a streaming fashion and perform matching to filter out all duplicates. A scoring engine helps determine the equality by assigning scores between two doma...
Perhaps im not defining my pytests right but im seeing this: Does pep8 demand a docstring for each unit test function too? I cant find pep8 docs specific to this, wondering if pep8/flake8 is unit test aware? I have many tests so this might be kind of a mess to have docstrings, but maybe I should have fewer tests with...
I am writing a bytecode interpreter in C for a simple programming language. I want to add GUI capabilities to the language. As a first step, I decided to bake into the interpreter a wrapper for the GTK library. It is exposed to user code as a builtin module. My problem is that GTK works by taking control of the thread:...
I'm writing a library which includes some wrapper code for some underlying API. In that underlying API, there are two concepts, "foo" and "bar", whose literal meaning in the English dictionary is close to the switching of their meaning in the API. i.e. it uses "foo" for something that's close to "bar" and vice-versa. ...
I have a backend Spring Boot API that should have one(?) endpoint that returns some statistics to display in a frontend. These statistics are calculated from data that comes from two different databases. Now since I'm using Spring Boot, I understand that each Controller should have a Service and each Service should ha...
I have been learning Backend development for quite a while now and I decided to build a bigger project using Express.js and the MVC architecture, the project is basically a Restful API with Vue.js in the frontend (it may contain some real-time communication later as well). Since I am not from a CS background, I have st...
I sometimes write Java code that looks like: success: { fail: { if (...) break fail; // some code if (...) break fail; // some code if (...) break fail; // some code break success; } // failure handling code } Is this bad practice? I could extract thi...
I have read several times that a Microservice should be an independent software unit. But what does that mean exactly and is it really achievable for each business case? Does that mean that I can run a microservice stand alone without any other microservice and use the full functionality of that microservice? Or do I g...
While going over a java book I came across this phrase: Different JVMs can run threads in profoundly different ways. While it's completely understandable to me that code can behave differently depending on the underlying JVM implementation, it does bring up the question. Why are there multiple different implementatio...
Can anybody point me to the official source where it is explained what are operators and operands in Halstead Metrics for code, I would prefer the original paper by Halstead. Please don't post the Wikipedia link as anyone can edit the page. My original question is, let's say there is a function "fun" taking one value ...
We have 800-900 services we expose via an ESB. Each service is a web app hosted on Tomcat servers. We have 4 tomcat servers per group of services. Our services are split into 4 groups. Each service (web app) is free to include external libraries in their WEB-INF\lib folder. The server class path tomcat\lib only contain...
I'm trying to build a distributed system and have been researching how best to manage dependencies between services. The common example in tutorials is an ordering system - let's say I have a Catalog, Order and Account service. The Order service needs to accept an order containing a number of items, cost up the total ...
Let's assume that I have an attribute called Ticket_Case that has a predefined value (for the sake of arguments, say 1 to 20) that model different real-life use cases. They are an attribute to an ticket itself. In a different context of the system, I need to generate different messages based on the ticket case. These s...
We have a scenario where we'd like to use two branches in our git workflow, otherwise known as develop and master. The current flow is as follows: Create feat-branch - this branch will be based off of master. Make your changes in feat-branch, then finally commit your changes, and push them upstream to the remote feat-...
Lets say you have a class that has the responsibility producing a set of finished data, but the method of producing that data is intentionally an implementation detail and as such should be left inaccessible to clients. How do you unit test such an API, knowing as the implementor that the data will change over time? Id...
I have been experimenting with the idea of function classes as explained in this article and Composition applied to function dependencies as described in the following questions: https://stackoverflow.com/questions/58354848/seeking-common-ground-between-object-oriented-structures-and-mathematical-logic https://stackov...
I have a web application that is running under .NET framework and that is using JS/JQuery on the client side. I am the owner and the only developer of this web application, and it is not totally under production. This just to say that I can change the whole architecture of this application with no problem. I want to i...
I know there is plenty of questions about this, but there is a lot of seemingly conflicting information. My assumption: The viewmodel is an abstraction of the view, an interface to the business logic, if you will. Therefor if the viewmodel is an abstraction of the view, it makes sense for it not to depend on its imp...
I'm reading a paper and they use the term "discriminative power" in reference to a recognizer for road sign recognition. What exactly is discriminative power?
Often, when programming, you'll have different degrees of information to you in different contexts. For example, a web server may have two routes, which recieve information about a Person, one of these routes receives a Person with a Name and an id, and the other just receives a Name. We want to write code that looks...
I have 2 Aggregate Root: One is the Lessor user, and the other is the Lessee user. class Lessor extends AggregateRoot {} class Lessee extends AggregateRoot {} Each of these Aggregate Roots has a email property, it is a Value Object. class Email extends ValueObject { } class Lessor extends AggregateRoot { private...
Setup Say I have a database table called Events which contains events for when a user becomes active or inactive EventId|Timestamp |User|Status | -------|--------------|----|--------| 1 |11/03/20 04:34|A |ACTIVE | 2 |11/03/20 05:11|A |INACTIVE| 3 |11/03/20 05:15|A |ACTIVE | 4 |11/03/20 ...
How do you successfully adopt TDD in an organization? Training alone is not enough in my opinion as I feel it requires a change in process and mindset. If TDD has been implemented in your organization can you provide what steps/approach were taken to successfully implemented.
Why does Java's V Map.put(K key, V value) not comply to the Command-Query Separation?
Consider the construction of the FixAcceptor type below. The code snippet is part of a unit test. var logSource = LogSource.OnMessage | LogSource.Event; var stateStore = new StateStore(); var newOrderSingleMessageValidator = new NewOrderSingleMessageMessageValidator(); var newOrderSingleMessageHandler = new NewOrderSi...
There are multiple aspects and quality that are desirable for a distributed system. Among these are consistency and availability. According to the CAP theorem, if partition tolerance is a must, the system designer can choose from a spectrum of models that trade off between consistency and availability. Jepsen provides ...
I'm writing a Software Requirements Specification (SRS) document compliant with the standard IEEE-830-1998. I've also drawn a couple of UML diagrams, specifically a use case and an activity diagram. I wonder whether is correct to insert those diagrams inside the SRS. And, if that is the case, in which section of SRS s...
I know the fact that global mutable variables are bad as they can be accidentally modified and make testing difficult. However, there are situations when a class needs to cache some information, for e.g. caching the time when the last request was made to a public function of a class, and this information is totally pri...
The question is related to software engineering best practice. If I have a function foo() that needs some non-trivial variables (say some 2D arrays) to be set before it can perform its action, is it better to have the caller set those variables and pass them on when it calls foo(), or is it better to write foo() such t...
I am analysing a Windows Forms application in .NET Framework 4.5.2 with 4 separate solutions with a combined 1.5million lines of code (and 10 years of development) Libraries.sln (54 projects) Tools.sln (18 projects with many depending on 28 projects in Libraries) MainApp.sln (140 projects with many depending on 28 pro...
There's a scenario I have where, in the main entry point of my C# program, I iterate a directory of managed DLLs, load each of them, and pass a factory object to each of them to get a mapping of implementations for various public interfaces. After the iteration is completed, I have one big map of interfaces and their c...
I am trying to use EF6 with my project. I just watched Repository Pattern with C# and Entity Framework, Done Right | Mosh video. I understand the necessity of Repositories but I still don't understand UnitOfWork. I already have my DBContext to use instead of UnitOfWork. In the sample code of the video it is like: using...
I'd like to match a regex pattern on a stream, but I am not sure what algorithm to use. I certainly don't want to load the entire file into memory. I tried to figure out how to do this, but I have only very basic ideas. For example I could concat the chunks into some sort of aggregate string as long as I find a match....
I want ask experienced software developers and architects about best architectural practices for the following problem. Suppose we have two entities: Student and Teacher and each of these two entities has an image. How can i model the database? A single "Image" table with two nullable foreign keys (to reference the stu...
I have a aggregate root called "Billing Document" which has some additional entities as attributes ("Billing lines"). I want to persist these objects together into my database. I read about the repository pattern in combination with a mapperclass. this would be a good solution in my eyes. My domain objects don't need t...
I want to release a program, my first program, but I don't know how to protect it. By protecting it I mean protect it against piracy and getting copied by others. Is there anything I can do to protect it? Can I protect the program or the code?
I have a the requirement for a webservice which should return a "business log" of the action the service performed. Usually I only return error logs which are based on exceptions. the exceptions get aggregated to a log at the top most level in the webservice. Injecting a logger-object into every business class so it co...
I have been struggling with this concept in the context of web applications ever since I first read about it. The theory states that the domain objects should encapsulate their behaviour and business logic. A model which contains only data and has its logic somewhere outside is called an "anemic domain model", which is...
Assume I have module of classes: EntityLoader loads some entity by id. EntityValidator checks preconditions, input data before saving changes. EntityUpdater saves changes. EntityLoader has method loadById($entityId), it loads data and caches it in own state. It is called in EntityValidator first, and is called in Ent...
I have a requirement to list country codes (e.g. CA, US) by username. A single user may have zero, one or more countries and a single username. A country has a single country code. I have a UserRepository and a CountryRepository. My question is - which repository should I be putting this code into? Is there a generally...
I have many dependent statements. What is the best approach to handle these cases dynamically? Example enum UserType { case buyer case seller } enum ViewType { case active case inactive } enum ActionType { case buy case offer } These types are retrieved from an API. I have a matrix of...
This is a general software architecture related question. This question is not related to a specifc programming language or service. The question is: "Should a server do things on behalf of the user without user interaction by providing the users credentials (e.g. token or certificate)?" The following diagram shows one...
Let's say you need to create an API around machines, and you want to be able to query machines many different ways: Get List of all Machines Get Machine By ID Get Machines By Client Get Machines By Type Get Machines By Mfg Date Get Machines By Foo Get Machines By Bar You get the idea. And keep in mind this is a very ...
I often find myself creating class cycles by using the observer pattern. Consider the following scenario: I have a central accessible global data source (Subject) The data source is reflected by many GUI components (Observers) in various ways (e.g. different states for buttons, size indicators, numbers, etc.) Some of ...
I recall seeing a large email corporation discourage POP client access, suggesting it was insecure. Assuming this is not FUD meant to encourage adoption of their client, I am wondering whether either of these may be true: This has a basis in truth in that POP is insecure without the proper extensions, but POP can be a...
I am creating a system which makes static analysis on code when a commit to GitHub is made, the results are then showed as a GitHub review. My problem is, this means that the developer (actor) will not engage with my system, as it is actually GitHub that does this. The developer (actor) is using GitHub and will see the...
During my years developing software I have most of the times tried to improve the readability of my code. As one example, I often try not to use boolean flag parameters of methods and I try to refactor them when I encounter it. I know that using boolean parameters can be a sign of a problem in the design but it is usua...
I am working on a project which is introducing a new Business Product, that is leveraging existing systems From a requirements perspective, they fall into all these types: A system change is required --> i.e. new field, field modification Plain use of the existing field --> i.e. field will be used as it currently does...
Say I have some code which consumes a class called Subject, which implements ISubject. Would there be any concerns if I were to build a ProxySubject, which inherits Subject? I like this style because it makes it so simple to wrap the real subject: ProxySubject inherits Subject and overrides the required fields (mostly ...
I am modifying a software which is for trash collection. While reading the code, I asked myself is there any formula or trick to quickly calculate the number of time the statement gets executed inside the nested loop rather than doing it manually in head. Here's the kinda pseudo code for this---- for(i=1; i<=9;i++) { ...
I'm working on a fairly large c++ project which uses boost's serialization. The issue that I have with the way it is currently organized is that serialization is weaved into the main source code on all levels of the application from gui to the core. But sometimes I need to build the core (or other components) separatel...
I am implementing a feature in an app where a user can unlock achievements, and when the client requests what achievements the user has unlocked, the client needs to know the user hasn't seen it before. There are UI considerations around new achievements vs. old ones. The only way I can see solving this nicely is to b...
The main source of D3js solutions is observableHq.com, but seems impossible (?) to reuse algorithms by copy/paste... Is it? Even checking tutorials like this, there are no simple way (with less plugins or programmer's time-consumtion!) to check and reuse. Example: I need a fresh 2020 D3js v5 algorithm for indented-tree...
I have been wondering about this issue for quiet some time now. I find interesting and I have not been able to come up with a solution. This must be seen in a context of a shopping cart where you can first choose to add 1 gold bar to your cart and then add another 2, so the sum is 3. Let's say we have these products: 1...
I am working on wrapping an old project written in C# in a test framework. The largest problem I have is that I have a bunch of classes that are all VERY tightly coupled with other classes. All of these classes also make their own calls to the database, and many classes instantiate others directly within their methods....
I have an Angular SPA and I spun up my own basic form-based authentication using a .net core web API and SQL server to store user accounts / hashed and salted credentials. This is obviously not an ideal way to handle auth and it was only meant to be temporary. I have since gotten a request to integrate Azure AD, SSO fo...
Moved I originally posted this on SoftwareEngineering because that's where this related question was; but having looked into the Help in detail, I think my question is more on-topic for stackoverflow, and I'm moving it there. Will probably delete this question once the move is complete. Sorry I can't move the comments,...
Assume we have data structure objects - some of them are DTOs and some of them are VOs. Also assume that Value Objects are immutable and Data Transfer Objects are immutable and readonly, then: How would you generally call/define mutable data structures? Note that they aren't entities either because they don't have iden...
Is it bad for a REST API to have non-unique ID for a child resource? For example, the endpoint is: GET /parent/:parent_name/child/:child_name The :parent_name is unique, but a :child_name is only unique for that parent. I decided to use names at first because the parent and child are resources that exist in external sy...
I know that Python is an interpreted language and that c++ is a compiled one, or at least I like to think that I've understood some of their differences. Although C++ is apparently faster than python, what if you compiled Python code to an exe: Would they be the same speed or will C++ still be much faster?
I am very new to UML and UML activity diagrams. my question is suppose in a student course registration system after student successfully login to the system there are 3 options add course, delete course or review courses then how we can implement this in UML activity diagram. can I use fork here ? but I know fork is u...
Why there are only Domain Events (not talking about CQRS) in the Domain-Driven Design theory? Domain Commands like CreateOrder or CollectPayment seem to be a valid concept as well. Is there a reason for this? Or are commands seen as a subset of events?
I’m developing a Matlab GUI for a scientific computing application and need to plot fairly heavy intermediate results. Currently, the computation is represented as a function. The GUI accepts user input and passes it to the computation function, which returns the final data results. Architecturally, the GUI incorporat...
I am learning to create Use Case diagrams using the UML specification, but I have a couple of doubts about Use Case relationships which I cannot solve on my own. My question regards two different situations: the completion of a specific Use Case is a pre-condition for the execution of another Use Case. I have seen in ...
So I have an problem regarding logic I cant wrap my head around. I need to expand my application to two different countries which both have their own respective languages (some countries require up to 3 languages). As it turns out Country2 and Country3 have totally different views and logic for some of the major compon...
I had a quick question. I was working on understanding malware and then I started to wonder how was malware able to run on its own when installed? So for example, I was to click on a bad link that someone sent me, the malware installs on my computer, but isn't that it...the file is installed but it can't run unless I c...
I'm working on a blog-like application with Flask and SQLAlchemy and I'm unsure how to store the blog posts (articles) in the database. These are going to contain text and images (placed between paragraphaphs). I expect the text to have formatting, with bold, italic, different font sizes, etc. Would markup be a good op...
Edit -- I have no limited my question down to a more specific question. Is there an argument not to wrap a 3rd party user input validation library? To me there are a few strong arguments to do so. 1) By writing a wrapper it makes it easy for me to extend or inject additional implementation into the library. 2) If I ch...
I am coming from a typical monolithic background and I've been experimenting a lot with Spring Framework. I have also build some simple microservices communicating with each other etc. Now I want to go a step forward and build my one more complex app based on microservices. Right now I am on the phase where I am doing...
I am building a mini SQL parser that reads and converts SELECT, INSERT, UPDATE and DELETE statements into an AST. My current design is as follows: Statement.java: public interface Statement { String getOperation(); String getTable(); Map<String, Object> getColumns(); String getConditions(); } Select.ja...
We have a system consisting of Detectors Converters/Transformers Business Rules Engines and State Managers Views/Displays/Applications There are several potential ways these may interact and share state Message passing mediated by Queues Point to Point Message Passing via Http Shared State in a Database/Datastore ...
I'm working on a solution to "suspend / hibernate and resume" an application written in C # /. Net and looking for the right name for it. This solution "hibernate" the completed thread, allows you to save its state (stack, local data ...) to disk and restart (from hibernation). Something like the hibernation function i...
Consider the following JavaScript code: class MyClass { #myPrivateField; constructor() { #myPrivateField = new AnotherClass(); this.theGetter.method1(); // or: this.#myPrivateField.method1(); this.theGetter.method2(); // or: this.#myPrivateField.method2(); } get theGetter() { return...
Hi I am trying to create a role based dynamic route authorization system on my NodeJS ExpressJS powered API server. Scenario: There will be some roles like Admin, StandardUser etc. and they can't be edited or removed. More roles can be added by authorized users dynamically. These roles of course can be edited or remo...
Imagine you have software component named A which knows component B Lets say knowing each other is via reference or imports, or two of them. Is it safe to tell the following statements: 1. A-->B this connection is loosely coupled? If it was also in addition that B knows A (B-->A) then we could safely say that compone...
I am in the process of implementing a persistent collection in C, specifically, an immutable hash trie. In order to increase acceptance and reusability, I have identified the following key areas that should be abstracted: typing of key and value allocation & freeing of additional nodes Typing of key and value also co...
Can requirements be expressed in class-diagrams? For example: A student can enroll in a class. There are different classes. Some classes have dependencies, e.g. you can't go to Spanish III before you went to Spanish II and Spanish I. How to model that?
While making an application I've come to the point where I want to add logging for the inevitable case when something goes wrong. Now this seems like a problem that should have been solved decades ago, and indeed - there's no shortage of logging libraries for any decent programming language. But while trying to choose ...
I need 16GB RAM on my development machine to do some Android programming but I can't really afford to buy a new one. So, what's there to stop me from just creating a VM on Azure, use it for just a few hours every day (since its billed per second) and save a lot of costs? If I am using Azure's spot instances, I am getti...
I'm using a DDD approach for the Domain classes. Although, I have a problem on my design, that I'm handling it now but didn't have a good idea to over tackle it. My Architecture is the follow one: - Core Application(here I have a bunch of command/queries that use Domain entities and CQRS to process use cases) Domain ...
We have a large monolithic database. As part of a new requirement, I am proposing to move our financial transactional system into a new separate database via microservice-esque services. These financial transactions are very important for our customers and performance is key. It’s a very large module with a lot of busi...
This was very often in the past center of discussion, whether to use GET or POST for searchin. If you are making for example geospatial request, both values are needed (lat and long). If you do it with GET, you cannot really annotate in openapi that both fields should be dependent on each other - the whole group lat/lo...
I am wondering how software with premium modes, such as Spotify, can operate offline. If a user is not connected to the internet, then they cannot authenticate via a remote server, which has e.g. a database of users and when their accounts expire. The only explanation I can think of is that the software locally stores ...
Often enough, the terms data model and data format are used interchangeably, but here I disagree. Let's start with the simpler one, the data format. I don't know exact definitions, but the data format describes the layout of a piece of data, the meaning of the individual bytes. There are many formats available, more ge...