instruction
stringlengths
34
36.1k
Overview I'm trying to wrap my head around the best-practice way to link Aggregate Roots together without transferring a lot of the business logic from the Entities/AR's themselves to Services, all while still adhering to the Vaughn Vernon tip to: Prefer references to external Aggregates only by their globally unique ...
Elastic search is basically about indexing of data. In database world, Multiple indexes can be created on a MongoDB collection Collection in MongoDB can be schema-less. In MongoDB, BSON encoding of JSON syntax is used to communicate queries to MongoDB In Elastic search, indexing is performed on such schema-less docume...
Currently in my office we have an age old problem, which I feel has been discussed to death by many, yet solved by few. The clients want a monetary amount, project managers want to know how many hours it will take, and developers only want to discuss in terms of effort. How do you approach appeasing all of the three d...
All,We need a convention to assign a version number for our product. After I research. I found this post answer my question. And it lead me to the http://semver.org/, The Semantic Versioning Specification. I think almost everything in the Semantic Versioning make sense to me .But only one thing I didn't understand . In...
I know synchronous communication between services is an anti-pattern, so I'm searching for a good solution for my use-case. I have this two services: Location Service that manages users location Score Service that manages users score Now, I have to build another service: Users Feed Service (UFS). It has to return use...
This question might have been asked before, but I am unable to find it. So here goes: I am writing a program which connects to several databases (one at a time). It is using OleDbConnection at the moment, but will be changed to SqlConnection at some point. Should I create, and open a new connection every time, or simpl...
How does one conceptually manage date-ranges, specifically the ending-date when there is a time-component involved (as in JavaScripts Date, C# DateTime, MS-SQLs datetime2). For example, humans saying "from 01-07-2017 to 10-07-2017" would give the mental model of both dates being inclusive (at least in most cases in my...
I am interested in zcash (https://github.com/zcash/zcash) and the theory behind it. Therefore, I download the source codes of zcash to trace it. The codes comprise C++,python and shell scripts. How to determine the behavior of these codes quickly? I tried UML revere engineering, but doesn't really help.
We're currently building a library in C that configures itself from tables in EEPROM. This leaves the possibility however that some caller requests a field that is out of bounds, and the question then is, what can we do about that? We've been thinking about an optional here, but since we're implementing our own error ...
We have a microservices architecture. One of the components is an Authentication & Authorization Service, which implements OAuth2 standard using encrypted JWTs. On each authentication of a user to any component, the component sends a REST to the service to get an access token. On each REST interaction of a user to any ...
We are using StructureMap in a new software development project. One of the team members has implemented a unit test that basically tests the StructureMap container configuration. It does this by doing the following; Counts number of instances of assemblies that are configured for classes in our application namespace....
As defined in Software Systems Architecture (chapter 3 - Viewpoints and Views) a view describes a particular aspect of architecture, and a viewpoint is a collection of patterns, templates, and conventions for constructing one type of view. From this I do assume that only one view will be constructed from a viewpoint. B...
Since the Go lang is getting popular, I started to play with it. I do derive from Java language so when I saw the Go syntax it has been a bit strange to me. sample code from go lang project site: func NewField(w, h int) *Field { s := make([][]bool, h) for i := range s { s[i] = make([]bool, w) } ...
We have an MVC 5 based web application. Part of functionality includes displaying hierarchical structure as a tree (I use this JavaScript component: https://www.jstree.com/) Tree is displayed in the left part of the screen and is several levels deep. Each level represents different object type. When user clicks on the ...
I am working on a little project (in a very "low Level" language with single-precision 32-bit float that nearly has no functionality apart from basic conditions and loops) and at one point I have to solve a linear system of equations (4x4 or sometimes 5x5). This is not the problem, I use the GAUSSian algorithm with piv...
Netflix conductor allows you to implement complex business and process flows using a JSON DSL. I do understand the scheduled nature of Conductor, still, in what way, it is different from having a BPEL engine in the good old SOA world? Also, who should own the governance and maintenance of Workflows?
This question is more of a general question about how to model simple one-to-many relations using collections: should a change in a list item be reflected in the version of the aggregate containing it? The domain is about meeting scheduling (like in Outlook). I have a Meeting entity, which can have multiple Participant...
To some of my tables I want to add "second_primary_key" which will be uuid or some random long key. I need it because for some tables I don't want to expose integers to my web application. That is, on a page "/invoices" I have a list of invoices and a link to "/invoices/:id" where :id is an integer. I don't want a user...
When testing, sometimes a helper method can be useful for repeated task e.g. in test setup. Concrete example: We have certain tests against our rest interface using Spring's RestTemplate. To make it easier, the requests are sent with the help of a helper method (let's call it method A() for now), which returns the ob...
I'm having doubts about how to implement and keep synchronization between two datasources in a distributed system. In my case, I have a service that checks for expired jobs in a repository. If the job has expired, then it is removed from the repository and enqueued in a distributed queue (the example is in Python but s...
The dependency rule in Clean Architecture states that: ... that source code dependencies can only point inwards. I now came across a problem that I cannot figure out myself. Lets assume I have a module with application business rules abr and 2 modules for services that implement interfaces from abr. +----...
I understand there are many questions in this site revolving around the same concept, but I could not get a precise answer for my case. Problem I am handling an ERP System, with code base in both: VB.NET/ASP Forms for the user interface portion of the system TSQL Stored Procedures on SQL Server, handling business logi...
Having single (or few) method(s) interface constructor injection should I store in a field a reference to the interface instance passed as is or just necessary "entry point(s)"? class Client { private readonly ITool _tool; public Client(ITool tool) => _tool = tool; ... } or class Client { private reado...
Quoting from Vaughn Vernon: When two or more Aggregates have at least some dependencies on updates, use eventual consistency. He further goes on to suggest that one could make use of Domain Events to publish actions to the other Aggregate Roots that need to be updated. He further proceeds to explain that Eventual Co...
Actually in the company that I work there isn't a procedure or any kind of methodology choose to develop software. The software developed is administrative to the own company, clients applications many of them data driven and some outsourcing wherever the occasion arise. My manager give me the task to create a set of p...
Imagine while using the command pattern, I have a quite a few different commands (> 30), now most of them are very similar but they depend upon an answer after execution (think in a dinner example, as the waiter needing feedback from the guest, whether they received the right meal). Now basically I could reduce the num...
What I want to achieve: I need to obtain a run time (unique) id for "any object" (for classes either in java SE, classes I have created or classes provided by other third parties... any instance of a class). Ideally it should be as easy as: Map<Object, UUID> objId = new HashMap<>(); MyClassFoo foo = new MyClassFoo(); U...
I'm getting ready to create an integration with a major external system and was wondering if my understanding of the design pattern for this in domain driven design was solid. Considerations: External System serves SOAP, mine's a web api 2 solution. Full CRUD operations across many SOAP methods My thoughts: Create a g...
The DbContext of my application's Entity Framework setup (which I will refer to as ApplicationContext, the name of our derived type) contains classes for all of the tables in our SQL Server database, rather than having them spread out across multiple DbContext classes. One of the issues we've run into is, because EF us...
I've set our sprints up to last for 2 weeks, nominally 10 days. Day 1 starts with planning and then moves to start development. Day 10 has S&T and Retro, but also cleans up the release/tidies the Boards/backlog etc. It's now been suggested to me that a 10 day sprint should have 10 days of development, and then a deli...
There is some information about how to package HTML5 app to use on Android or iOS, but I couldn't find anything about a normal website. Let's say I would like to create a website displaying multiple HTML5 interactive animations/apps, and I would like to have clear way of adding more of them. With SWF files the problem ...
This question about when to use private and when to use protected in classes got me to think. (I'll extend this question also to final classes and methods, since it is related. I'm programming in Java, but I think this is relevant to every OOP language) The accepted answer sais: A good rule of thumb is: make everythin...
This is the ER diagram example from the Wikipedia. Here they have marked the Orders entity as a strong entity. As I understand a weak entity is an entity which cannot exist without a corresponding strong entity. In this case, I think the Orders entity is existence-depended on the Customer entity. Because an Order wo...
I've been developing my scientific-computation software for a few years in C++ and it performs pretty well on CFD and DEM simulations. However, it has about 12k lines of code without the dependencies. Any time I peek into another project, I'm always surprised how much lines are written even in a 'simple' project on rat...
I was reading through Groovy in Action, Second Edition and on a footnote, I found the following text Java pours “syntax vinegar” over such a construct to discourage programmers from using it. What does the term syntax vinegar means here? I have never heard of this term before and searched on DuckDuckGo and Google but...
I have been given the task to create a system in which users can buy intellectual property (broadly categorized, hard to explain what they are really buying) from the system and can transfer funds between each other. For the purpose I have created a transactions table which holds the sender, receiver and amount. For pe...
The following procedure: We have Development branch and Developer create feature branch from Development Work and commit in this branch Rebase from Development Create pull request Code review Merge with Development Problem that we should have 2 level code review, performing by different people. After first review app...
I'm currently working in an environment where I have the following: Multiple Inputs (with multiple versions) Source code to generate output (multiple versions) Output generated by a combination of input and source code The top level directory looks like this: inputs/ outputs/ src/ I'd like to somewhat generalize thi...
Our company is deciding on a policy regarding the use of type inference in our C# and Visual Basic.NET code. During our discussions of what type inference is, one of our developers raised an objection based on an argument made by Andrew Troelson. I've tracked this argument down, and I'm presenting it here because I wan...
There a lot's of SO questions asking "how" to get unknown JSON keys from a JSON object, and I've done it plenty of times, but after starting to use JSON schema to start designing API request and responses, I am starting to question if having unknown or even dynamic keys that the JSON consumer has to be smart enough to ...
I'm currently developing a project which has multiple c++ programs communicating over IPC to each other. Each of these programs will rely on some parameters to run and these may be common to several programs, e.g.parameters for camera calibration, minNeighbours, scaling factor, etc. I am wondering what the best practic...
I'm making from scratch the website of my agency, an online food order and delivery service. I'm trying to improve at best the promotion system: every restaurant has its own promotions, and some of them has a certain priority above others. For example, if the client orders three pizzas and for every ordered pizza ther...
Note that my question is not platform specific so that's why I don't add the [kotlin] tag (the code is in Kotlin). If there is a Kotlin-specific answer I'd like to hear about it though I am working on a simple component (GUI) library and I have the following interfaces: interface Component : Drawable, Positionable, Ide...
For example I have entities: Client, Report. Client may have many Reports and I think the endpoint for a single Report management should be nested like this: /clients/{client_id}/reports/{report_id} As for all the reports of one client the enpoint is expected: /clients/{client_id}/reports But how should look an endpo...
Should a resource be available through more than one URL endpoint? For instance, I have exam resources which contain multiple question resources which in turn contain multiple answer resources. The endpoints to list questions and view a single question are as follows: /api/exams/{exam_id}/questions /api/exams/{exam_id}...
Background I joined a company as a solutions architect less than a year ago, with a main task of consolidating, and modernizing legacy code resulting from 90+ company acquisitions over the past 20+ years. One of those legacy applications, is a desktop application written in VB 6.0 that accesses a SQL Server database a...
In RDBMS, goals of Normalization: Free the database of modification anomalies Minimize re-design when extending Avoid bias toward any particular access pattern First step involves avoiding redundancy etc... As data is normalised and divided in multiple tables, join operations are required to satisfy queries placed by...
My data: Size - 15+ Terabytes of text. Data: Maximum of 1300 rows (always same row headers) , Maximum of 6 columns The column headers will be different but the value are all percent values that will be between 0 - 100. The total of the columns in one row will add up to 100% always. So we can get rid of one column rig...
Each data type must be aligned to a multiple of some number of bytes, for example a short int must be aligned to a multiple of 2 bytes, and an int must be aligned to a multiple of 4 bytes. But why data alignment is used exactly, is it because the CPU can only read from memory in multiple of some number, so for example ...
I read few sentences of this. I understand that simply put, the persistence layer (with its repository objects) deals with basic data access CRUD. The service layer on contains business logic. In my view, a service object contains multiples CRUD operation from one or more repository objects. Now I was reading in a boo...
I've seen the terms brittle and fragile used to describe poorly written unit tests. But I haven't been able to find a clear definition for what brittle or fragile actually mean in this context. Is it unit tests that break for more than one reason? Is it when a test fails because something in the code base is changed t...
As I know, on one hand, the main stream opinion about global variable is, it is eval because it may make the program unpredictable : some unknown class or functions can change the value of the global variable even if they don't need to do so, so it is bad to see this: public class User{ public String name; pub...
I m currently working on a React Native application which aims to provide à huge list of items, using infinite scroll and a local state (no matter the technology / plaform, it's stored in RAM) of the app. I've currently implemented it the following way : 30 items are rendered first Scroll to the bottom of the list Tri...
I am writing a small-ish console application. I took care to be able to test the important business parts of it in Unit Tests. But having most of it finished I realized I could just test the application as a whole. Basically, I could just test Main with the proper arguments so the application will "run through" all the...
I have written a simple class hierarchy to represent terms in Scala. Terms are recursive data types, e.g., a Sum and a Multiplication consist of the left-hand-side (lhs), which is a Term, and the right-hand-side (rhs), which is also a Term. Scala's pattern matching makes it easy to check if a Term has a given structure...
I am developing an application where part of the supported features may become optional in the future, so the user can enable/disable them. However I am not aware of an approach in handling such optional features in the code. Is it just like putting checks to see if the feature is enabled by the user or not, before e...
Let's say I've got a test builder, so that teachers can create a bunch of questions for a test. However, not all questions are the same: You have multiple choice, text box, matching, and so on. Each of these question types need to store different types of data, and need a different GUI for both the creator and for th...
I'm building an application which uses SQLite, and now want to add settings that are stored between sessions I'm considering if I'm going to store the settings in a config file or if I'm going to use a table in the database for this (Please note that I'm using SQLite which stores data locally and doesn't have a user ac...
I'm developing a photo sharing website. Currently, the way I wrote it, a user uploads a photo (jpeg), which is read in as a Base64URL (using FileReader). The backend (Django) uploads this file to Google Cloud Storage (using django-storages). The view renders (serializes) the images as signed urls which are then easily ...
I had a question regarding the performance of having a class implement multiple interfaces. Is there any degradation in having a class implement 2 interfaces vs 10 interfaces? Background This question comes from investigating Microsoft's Identity2. I noticed that there were ~6 replicated DB calls during the ClaimsId...
I'm having difficulty understanding why you should develop internal libraries to be used exclusively for developing internal applications. I appreciate that if I want to use software that someone outside the organisation has written then they can send me their header files and .a or .so files and I can just link it to ...
Is there any way to safely include libraries (either internal or external) in the directory of a project (say in a lib/ folder) when you ship or release code? As far as I can see it would be a lot easier if the library files the application depended on were placed there; that way, other people wanting to use the code w...
My class pseudo code is in the following format: public class Config { final private Map<String, TableSchema> schemas; public Config() { schemas = parseSchemas(); } public TableSchema getSchema(String tableName) { TableSchema tableSchema = schemas.get(tableName); if(/*Based on c...
Consider a common tutorial for object-oriented programming languages like C++ or Java: create a simple order processing system with objects representing accounts, orders, items etc (or something more or less equivalent). Makes perfect intuitive sense, but the elephant at the dining table is that it's not real because t...
I was wondering if what I have in mind already exists in any known compression programs/algorithms or not. We know that Seed gives us constant sequence of random numbers. so if we be able to find seed that say generate those bytes then we can compress files into just 1 magical seed that reproduces our data bytes! In o...
The main advantage of serverless architecture is said to be that such programs do not need a dedicated server to run continuously. Then are invoked on a request and stop on exiting the function. This means that a serverless program will have to be quick to start, for being responsive. How does then it handles time con...
Recently I started working on creating a client library. One problem which I am facing now is that I have to move the below interface Attributes to client library but the concrete classes (business logic) should remain in the original library. The problem here is that the method signatures of the below interface are Co...
I thinked at two techniques for my #define : Technique 1 SomeClass.h: #define SOME_BUFFER_LENGTH 256 class SomeClass { /* ... */ }; Technique 2 Config.h: #define SOME_BUFFER_LENGTH 256 #define SOME_OTHER_THING_USED_ELSEWHERE 23 SomeClass.h: #include "Config.h" #ifndef SOME_BUFFER_LENGTH #define SOME_BUFFER_LEN...
I'm working on a non-generic server-client-architecture in Java. Currently, I face the issue of how to tackle Event-types since each event has different attributes, which don't overlap neccessarily. For now this is what I tried: public interface Event { public void send(ServerConnection connection); } public static...
I have got a native image processing application that can enhance photos(peApp). Now, I want to serve this functionality to the world by having a server application that supports REST. Now while taking the scalability into account, I think I better seperate this project into 3 components: peApp : does only his comput...
Sounds pretty basic, I know, but I recently had a colleague tell me that a method called startHttpServer is too complicated to understand because it only starts the server if it's not already running. I find I get into trouble when I respond with, "Seriously? I've been doing this for decades - it's a common pattern in ...
Description: Given a parking lot containing multiple levels and each level containing multiple rows and each row in turn containing multiple spots. The questions is to determine if there are enough spots to check if a vehicle can be parked. Which object is responsible to determine if there is enough spots, I mean its t...
I've been reading about semantic versioning. Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. So, does doccomments above the public methods of my library counts as declaring a public API? class FooBar { /** ...
Background In a software ecosystem where different packages depend on different versions of other packages, sometimes dependency resolution ends in a version conflict. Example: Root package A depends on B 1.* and C 1.*. Package B depends on E 1.*. Package C depends on E 2.*. -> conflict. Maybe the developers of libra...
Context: I wanted to change a setting inside Xfce and found that the way to do it is via xfconf. My first thought was to install the development files for libxfconf (libxfconf-0-dev) and look into the API. I searched to see if there's an example in some open source project and found a library which, instead of using th...
I'm just designing the exception handling for the REST interface on our Spring server. As we will have multiple REST controllers, a central exception handling is desired. Spring offers the solution via @ControllerAdvice. This works well, except that I need to add a dependency to the MVC part of Spring, which I don't us...
I'm writing a interpreter/compiler I have encountered a problem which I have solved before, but not optimally perhaps. The problem goes like this, expressions can express a lot of things like scopes, variable assignments and declarations. When an expression is simple, for example: a = 4 + 3 turning it into a Reverse P...
I have a couple of derived classes that are generally similar, but don't have a directly shared base class. All these classes implement a common interface. I noticed when I added another (new) derived class, that I copy a couple of private methods from the other classes which have similar content, but the actual implem...
I have the following situation: ASP.NET Core WebAPI solution which uses Swagger Automatically generated client for WebAPI using Autorest, extended with custom authorization. This client also will be packed into NuGet to be used by other services. Question: should I place the client into the same solution(and thus in ...
I've been tasked with studying a Python code, which runs on an orchestrator, which schedule the launch of the code in correspondence of some events. The code imports some modules, and it's basically written as an extension of a method of a certain class, defined in the orchestrator module (is extension the correct term...
I want to develop a robust system written in C# (WPF and WCF) for importing .csv files (and/or some others e.g. Word files) as a input into my system and then to generate PDF/Word report. I would have database, and application will be a desktop app. I am just wondering is there any approach for multiple customers apart...
Background I am trying to write a simulator where multiple AI agents are competing and/or collaborating to achieve the goal of maximizing some utility function. Each agent has the ability to interact with the world where it might alter the state of the environment, based on some actions it does. And as a result of such...
I'm attempting to design a class that is to be instantiated through the use of a static method, something like newInstance(param1, param2). The reason behind this is that 2 of the 4 parameters it takes are from the same package, but I want to hide them from the public. In order to achieve this, I made the constructor p...
I have a project that depends on external libraries that can be installed through a package manager (pip in this case). But I do not expect my users to have knowledge of installing these dependencies or even have the package manager installed on their system. I will be using a different mode of distribution for this pi...
If I'm creating a Java class for something that has a sequence of numbers in its name, e.g. “ISO 8859-1”, how should I name my class? Iso88591 seems wrong, since there's no boundary between the numbers. Iso8859_1 seems better to me, but according to Effective Java “… Constant fields constitute the only recommended u...
Kotlin is known primarily as a drop-in replacement for Java, but it gets rid of a well-known Java construct: the static keyword. Instead, that class-level functionality is offered mainly by companion objects. What is wrong with static methods and fields that companion objects provide a better alternative to? I'm confu...
I have a telegram bot that alerts whenever a price of certain asset reach a certain price. I have the following table in a DB: AlertId ChatId Price Asset So each Asset will have several ChatId (users) and each of them can have several AlertId, and AlertID is a unique autonumeric value. As this data is constantly rea...
When reading grammars defined using Backus–Naur form (BNF), I've noticed that the grammars never seem to use an explicit repetition symbol, such as * or +. This is opposed to Extend Backus–Naur form however, which does seem to have explicit repetition symbols. The Wikipeida article on EBNF mentions this, specifically u...
Let's say I have an interface A. Instances of classes implementing this interface will be passed on to an algorithm that relies on these instances being immutable. For instance, it'll be invoking A.execute(command) in a recursive manner, a number of times that depends on the given parameters. If execute() changes the i...
I'm a hobbyist coder; never worked professionally. I am not looking for anyone to write code for me, but I need to know how to approach this problem and, perhaps, ideas for further research. This problem is an outgrowth of my kid's science project that I wanted to toy with. Bottom line is: I have a sensor that feeds da...
It's very common to specify the version of REST APIs in the URL, specifically at the beginning of path, i.e. something like: POST /api/v1/accounts GET /api/v1/accounts/details However, I haven't seen any design where the version is associated with each API. In other words, we maintain the version of each API separatel...
Imagine you have 2 use case A and B. To execute case B, A has to be already done ( A is precondition of B), but when you execute A you dont need to execute B Like this? User -> A User -> B -> include A
In my current project I have a situation where I would need to use an edge collection as vertex collection. I would like to find a way to avoid it. This is the (reduced) scenario. These are the vertexes: Pupil, School, Holiday These are the edges: visitsSchool Pupil | {from} +-------------> Holiday | {to} +...
I have a method which is a part of the interface I am implementing. This method calls another private method which uses a random number generator to produce output and returns it to the calling method. I want to test the calling method. How can I do that? This is the method under test: @Override public String generat...
What would be a clean design for an app that is to store transactions and return a overview of the ones received in the last 60 seconds, operating in constant time and memory (O(1))? The app should expose two endpoints, one of them to POST a new transaction, and the other one to GET the statistics based of the transact...
If a software/library has some support for the Windows platform they almost always name their directories and variables as win32. This is most prevalent in C/C++ projects. Even the MinGW project's target triple uses win32. Is there a reason for this? Why not use a proper name like Windows or Microsoft Windows? Is there...
I am wanting to develop a C# application that would allow me to right click on a file and choose an option within the context menu to perform a save as with a date time stamp and then open the newly created file. The process flow would look something like this: User right clicks on a file opening the context menu User...
If I have some code which assigns a value to a variable, and that value then does not change, is it considered good practice to use const during the assignment? e.g. void foo() { int n = some_function_which_computes_n(); // <-- this could (should?) be const // imagine some code here which uses n, but doesn't cha...
I'm building an application with a database where I'd like to populate the DB with some data at first start up (so that the user has a few examples of how the application can be used) To achieve this I'd like to detect if the application is started the first time and if that's the case add these initial rows to the dat...
I have to design a system where an API has to be hit to get the meta info about some data. We have multiple workers, that take jobs from multiple queues. Now the API has a rate limit of say 500 per minute. Since we are using python, so getting the interpreter lock and wait for the time interval won't work as workers h...