instruction
stringlengths
34
36.1k
I've been developing a non-trivial personal application and I thought I'd use CQRS to learn it. The application is very data entry heavy, lots of entities and lots of forms. I find myself constantly creating CRUD queries/commands and their respective handlers plus DTO's and I find myself thinking...this is all very exc...
I am trying to understand the benefits/gains of using standalone components in a real project that my team and myself included are working on, and from my very humble point of view, I just can't see much and I would like to hear feedback about it Without going too much in detail, the current project is using version 13...
In Python 3, I subclassed int to forbid the creation of negative integers: class PositiveInteger(int): def __new__(cls, value): if value <= 0: raise ValueError("value should be positive") return int.__new__(cls, value) Does this break Liskov Substitution Principle?
In the code snippet found in this tweet, pattern matching is used like this: let (|x| x) = |_| Some(1); // same as `let (x | x) = |_| Some(1);` Which threw me off. Rust's pattern syntax is defined as: Pattern : '|'? PatternNoTopAlt ('|' PatternNoTopAlt)* // ... It looks like the leading '|' was intentionally allowed,...
Let's say my language's standard library does not include TrickyFunction(). Since implementation seems quite trivial for me, I decide to create utils in the project and add such function, for others to use. Next month another programmer requires TrickyFunction. He doesn't expect it to exist, so instead he downloads and...
My team have recently inherited a very poorly written, business-critical, monolithic LAMP application with the goal of guaranteeing reasonably uptime and scalability targets in just a few weeks. Our deadline is somewhat fixed because it depends on user volumes over the peak season, which we forecast will start picking ...
I’m trying to test concurrently request (brute force test), with 1000 request/sec (same request id). I’m using Rest API. The service running on distributed system, I’m using 3 pods. The problem is I got duplication when inserting data, because we use distributed 3 pods consume concurrently (the request). Then I tried s...
It's been a long time since I worked with SOAP so my question might be trivial but I just wasn't able to find a satisfying answer so far! Anyways here's what's going on: I got access to a system via SOAP endpoints (Dev, Test and Prod) I used svcutil to create proxy classes (they are almost identical, only few lines di...
Is it an anti-pattern to have gaps in field numbers to aid readability? The need being address by this idea is that metadata fields, which are "aspect" fields, can be placed in the proto file away from the main fields, and by numbering them using high numbers their position in the definition will agree with their numbe...
I'm new here, so please be gentle. I've been having issues at my workplace about the front-end team demanding me as a backend to provide every piece of data that has to be displayed in the front end. I just recently get into this job after graduating college, so it kinda baffles me, because I never process every bit of...
I keep running into this problem when programming, and I wonder if someone has written about it before, or maybe developed some ideas about it. For an example program, lets say I have a graphics program that stores, in a data file, a Canvas, Layers, and Shapes. Each Canvas has a number of Layers, and each Layer has a n...
I am designing a job search app where I have entities like: Candidate User Company User Offers Province Entity related in One To Many relationship with Country University Entity related in One To Many relationship with Degree Entity. The Degree stores additional information about the Degree. The Candidate User, the C...
I am running a program that, among other things, does some matrix multiplications, singular value decompositions and accessing matrix subsets on a very large data set (these are the lines of code that take the most time). I am running computations on a CPU with 40 cores and 1TB RAM (yes, 1TB). The dataset itself is ~45...
I am trying to understand how a deployment diagram works by making one and reading up on it. I have come across multiple different (contradicting) statements or I am flat out misunderstanding them. According to Lucidcharts an artifact would be "A product developed by the software, symbolized by a rectangle with the nam...
When I have a class A in a module amod as follows // module amod type AConfig = { x: number; // ... }; class A { constructor(public config: AConfig) {} // ... } export {A, type AConfig} and want to decare a class B in a separate module bmod that makes use of A, what would be the better approach? Approach 1:...
I'm working on a python wrapper for a REST API. I'm using python data classes to store the shape of the JSON response of each endpoint so developers have features like autocomplete and objects they can use from the response. In 99% of the cases, I can maintain a separate python file for each end point. So for /cars end...
I'm working on a python library for a REST API.I'm using python data classes to represent the structure of the returned JSON The v2 of this API returns a slightly different object when compared to v1. Here's an example: v1 { "animal": { "breed": "retreiver", "color": "brown", "name": "spot" ...
I am trying to tinker with the MVC pattern and I have a problem when trying to design the MVC structure. I need a model for products, however as I need to manage more and different data, I can help but wanting to create more models. Would be correct having the following structure or I am not using the design pattern co...
currently in my place of work I'm headbutting with some coworkers from other teams (but same repo), since they are in a line of thinking where they prefer this: const connectionList = Object.values(connections).flat(); const connection = connectionList.find( conn => conn.in === Number(connectionId), ); Rather than j...
I have a set of data-struct like classes that correspond to the JSON messages being exchanged between services in an overall architecture. By struct like, I mean these classes just have fields -- no member functions -- and are implemented using pydantic since this makes for easy development using fastapi. There is c...
Using a ton of libraries, IO, ... you cannot handle all imaginary errors. You will need some form of "catch uncaught exception" handling to still have a control flow for such a case. But if you are aware of such an error, you usually can and want to add a proper handling. That brings up the paradoxical question of how ...
I am writing a custom python package, which produces some files in a certain directory. This directory I call root_path and should be set by the user. So basically, it should be a conf variable but not stored in a file. At importing the package, my code looks as follows: import my_package my_package.Conf.root_path = "...
I have an existing repository (which is organised using the standard Golang project layout) cmd/ bigproject/ main.go internal/ ... pkg/ ... vendor/ ... What I would like to do is add an extra directory inside cmd which contains an alternative main application: cmd/ bigproject/ main....
In the observer pattern, and similar, is there a meaningful difference between "subscribers" and "observers" in the wild, or in the lit? With RxJS and (functional) reactive programming, are the terms interchangeable?
I am challenged to rebuild a support ticket manager app currently on legacy PHP code. I plan to migrate to microservices + JS frontend technology like VueJS or React. One of the app's page is a support ticket page, with a comment section. There is currently a trigger that registers the visit date of a user on the page ...
I have been asked by the BA/PM community in my company how DDD/domain modelling can be used as a tool when deciding how to form, split teams and how to decide their missions. I have my own thoughts on this, mostly realising DDD was not meant as a tool for team composition. However, I wouldn't rule out using the outputs...
I have a situation where I want to run a complex algorithm consisting of many subtasks in parallel on a number of processors. These subtasks depend on one another, so that this algorithm is characterized by a DAG1 of subtasks. An arrow from A to B in the DAG means that subtask A must be completed before subtask B start...
I have an existing system that inserts books into a library database, and I want to generalize it to include other media. The other media is similar, but not exactly the same, and all media are third party dependencies/models that I cannot change myself. (Otherwise I would have them all implement a single interface). I...
What is a good way of handling version bumps in git history? The best approach that I've found so far is something like this: Version is specified in one of the source files (e.g. Python's __version__) Do not merge PRs unless the also bump the version All commits against master must also bump version I block commits a...
I have an endpoint in API 1 (my api) that queries API 2 (another companies api) to view and edit objects stored in API 2's database. API 1 is essentially acting as a wrapper service around API 2, providing some extra functionality. If a call to API 2 within API 1 ends up with a 404 being returned (in my case because an...
I have to implement a bi-directional communication between two local process with support to backward compatibility .NET Core/NET Framework and platform architecture x86/x64. The options that i have explored so far are: HTTP: gRPC seems like a good solution since it manages the payload serialization, requests timeouts...
When I started programming, I learned what Pointers are in C++. In Java, references are variables which hold the address of an object. So conceptually it's a pointer, without the ability to directly manipulate it. Later I applied that concept to a lot of other languages, and it all seemed to make perfect sense. So the ...
I am making a game of Monopoly. I call a method in my Board class which returns the current players square object! E.g Old Kent Road. Euston, Chance , Free parking. I use polymorphism to decide upon the logic of what should happen depending of the state of the square! E.g I’ll have a property class where a the polymorp...
We're busy with a proof-of-concept to replace an existing system, but there's disagreement on how one limits the scope of the use case(s). We're managing multiple resources across multiple projects so we're looking for a POC to show that a new solution would help us better do resource planning. The direction the POC ha...
I'm trying to model the evolution of a player's energy in a game. I have an "alive" state, and a transition to it from the initial pseudostate that has the effect of setting the initial energy to 100: (initial) ---( / energy = 100 )--> (Alive) The player loses 1 energy point for each step he takes which I modeled ...
I'm in the mobile development domain and I use semantic versioning to version my releases. I keep both versions the same as long as new builds are released for both iOS and Android platforms at the same time. But imagine I fix a bug that appeared only on iOS. Now I have to release a new iOS build so I increase the buil...
First, let me start by saying I’m a JavaScript developer but any conceptual advice I’d imagine is identical if not similar to when dealing with MVC. During my learning, I stumbled across MVC and now most of the projects I do are implemented in this pattern. Even if it’s overkill sometimes I still do it to learn the bes...
I come from C++ background. One of the things I enjoyed was having a small scope for variables defined in compound statements such as a loop. In Python, compound statements do not form a block and a variable defined in a suite is accessible outside of the compound statement. What is the rationale for this?
I try to have as many pure functions as possible, but if I can't, I at least try to make the side effects as explicit as possible. Here is an example (in Go) type State struct { count int } func (s *State) IncreaseCount() *State { s.count += 1 return s } func main() { s := new(State) s = s.Increas...
I am writing a simple application to apply what I have learned so far in DDD. I have the following mysql tables in my api server Sales Column id pk, int title varchar description varchar Images Column id pk, int url varchar sale_id fk, int I have the following endpoints GET /v1/sales ...
I'm building an address book API, where a user can input multiple contact names, phone numbers, and addresses. My database structure would be as follows: create table user ( id int not null primary key, first_name varchar(100) not null, last_name varchar(100) not null, email_address varchar(100) not null ); create tab...
I have an App that connects with Salesforce and do different operations. So I'm trying to implement a Session Cache for the Application to avoid repetitive login calls. So far what I have done is I have created a ConcurrentHashMap which stores a Session Object (object consists of SessionID, CreatedTime, Validity, Servi...
Section 4.6.3 of ISO 13849-1 concerning "safety-related application software" has following provisions: c) Software design shall feature: semi-formal methods to describe data and control flow, e.g. state diagram or program flow chart, modular and structured programming predominantly realized by function blocks derivi...
I'm looking for a way to work with a huge amount (~10^9) of files (all sizes) in .NET using unspecified file system (NTFS, BTRFS...). What I have done up to now is to store them in evenly in a folder-tree so that no folder has any more than a couple of thousand files in it. The fs can handle it but there are other prob...
We have an existing CRUD-based system, but are hitting a number of pain points keeping the data organised for all the various views that are increasingly required of it. I'm assessing whether splitting the read and write models (i.e. CQRS) might provide some benefit here. The system handles the product catalogue for a...
I am supervising a university project on the topic of race detection for multi-threaded processes with shared memory. We have a complex algorithm consisting of tens of thousands of subtasks, and we are given a dependency graph over these subtasks. Our goal is to ensure that the output of the algorithm is deterministic,...
As we are implementing some stories we find some things which need to be put on a backlog as technical debt, often because there are larger questions linked to other stories or features which cannot be trivially answered and would derail our sprint goals. We might be bashing out a first version and want to make sure we...
Say I have a module storage-abstract, which contains abstract logic (framework) for storing key/values. I also have some (arbitrarily many) implementations of this abstraction, each in a separate module, like storage-files, storage-db, storage-cloud and so on. Now say that there is a class AbstractStorage in storage-ab...
I am wondering what a service layer is in MVC. I like to understand concepts through a game of monopoly as it's relatable to a lot of people and fairly easy to explain whilst allowing for some good OOP and SOLID principles to be implemented . Can someone tell me if this is the job of a service layer in an example descr...
The following design emerged from using Azure Durable Functions with lots of fan out, which turned out to not work very well. Our starting point was an Orchestrator with a companion Durable Entity for state keeping, and Activity functions for the actual work. We ran into several problems, like timeouts and too many ong...
Let's say we have a ecommerce platform. When user create order - we should make several actions like Send push to client Send push to custome Send emails e.t.c Generally I see two diffrent aproaches to arrange it. Is there some more right way to do it? First: In orderController Push One message "createOrder" to MQ: t...
I've been reading though Architecture for containerized .NET applications book, and I have a question about replicating data from from service into another: And finally (and this is where most of the issues arise when building microservices), if your initial microservice needs data that’s originally owned by other m...
First and foremost, let me say that I do not have a Software Engineering background . I need help from the community as I have been assigned to create a UML (Unified Modeling Language) design from aggregated Survey data on Public Transportation. I have been provided with around 42 tables (in Excel) showing the results ...
Let's pretend I'm making a basic twitter clone. We could imagine our database is set up as the following: 1. Table 1 - contains user info {username, password} 2. Table 2 - contains session info {username, session_id, expire} 3. Table 3 - contains post info {username, post_content, number_of_likes} These tables are bas...
Is there a best-practice pattern I can/should use for this scenario? I need access to some DI services in the OnFinished() method: public class Product { public int Quantity {get;set;} } public abstract class Job { public int Duration {get;set;} public object? Product {get;set;} public virtual ...
In short story, I want to make some universal generators for different formats (CSV, XLS, XLSX and JSON for now). Just to be clear, I will make different classes for all formats. I have different models, with different fields. For example: public class Agents { public int ID { get; set; } public stri...
I wrote a custom log handler that has a config file and uses a service on the network. Now I'm wondering if it should itself log. Pro: Everyone should log, it helps track errors, especially when you're relying on resources that can easily fail (config file, network service) Contra: In the case of a logging handler, ...
I'm working on a project where the master branch is protected. Usual workflow: Always create feature branches off master and then send PRs. Once that has been merged into origin/master, I can pull it into my local master then create some more feature branches off local/master to work. However I had a branch which was a...
Context: I am working on a project in which people use tags on commits yet in branches waiting on the Pull Requests queue of GitHub. This means they are non-merged to the main branch yet. The problem from my standpoint of view is that Pull Requests are unstable. Still as a PR, after some changes, interactive rebase, an...
I spend a lot of time lately talking about Microservices architecture and I have a really hard time buying all the benefits that are sold to me. For most arguments I hear I come to the conclusion that Clean Architecture can do just the same, especially when combined with strict implementation of architectural fitness f...
I need to design an application which makes requests to an external API. External API has a hierarchy of entities: User which contains ListOfItemss which contain Items. I need to get data on all Items for all Users. Within a ListOfItems requests per Item can be concurrent/parallel but only one ListOfItems can be reques...
From my understanding, a constant is a value which is assigned only once and cannot change at runtime, whereas variables have mutable values which are unpredictable by nature. My question is, to what extent can it be said that a value is known? Can values which are only assigned once but have some intrinsic "randomness...
I want to save an order with order items with prices in my write database. But firstly I need to fetch products with their prices because I don't trust a user - he could pass a lower price, that's why I don't want to add a Price property to CreateOrderDTO. Where should I fetch product prices? In a command handler - if ...
So I've been looking around to find a suitable hash function for a hashmap. Currently the best one I've found was from xxhash and maybe murmur after that, but they excluded CRC32C which can be optimized greatly by using 3 64 bit parallel crc32c instructions on SSE4.2 capable CPUs. CRC32 by itself seems to be quite outd...
I've got experience with WPF, but I have always been creating standard UI's. I want to build a drawing application for electrical wiring diagrams (single-wire diagrams). Example of the kind of drawings you should be able to draw: I want to start simple. But I don't know how to handle the drawing in WPF. I know, drawin...
I have an aggregate User and the user has a Score. The Score of a user is calculated by queriying a bunch of different tables and running through (often very large) result sets applying some business logic. Now from a business perspective in 95% of all cases only the Score of a given User is relevant and not the data t...
Let’s imagine system like Garmin connect, you run, record your workout and then once you finish workout is uploaded to the system and being analyzed. Based on analysis you can receive badge: for 5 km run, for 10 km run, for 3 runs in a row (3 days), for run in the morning etc. I assume that it is possible to enter new ...
Java is often (rightly IMHO criticized) for overusing the class keyword, as it can denote: a factory to instantiate objects (traditional classes) a collection of global methods (when all methods are static and there is a private constructor...the so-called "utility class" pattern) an application (when it holds a publi...
This is in context of a distributed computing. There is a Service A which owns a database and hosts APIs for updating an entities in this database. As time went by, the service has evolved and we are about to add a complex capability to this service. This capability can be separated out to a service of it's own. But it...
I was submitting this code in Java to an AI tool that checks for OOPS modeling and it says that this class is breaking encapsulation, although it did not gave any reason why. The objective is to store the three types of subscription for a user (music, video or podcast) and add a topup only if atleast one type of subscr...
I'm trying to understand the CQRS design. As far as I know now, every time a change to a model is saved, the (state) change is stored as a separate record. When reading a model, the model is constructed of the changes that are stored. Like: Model User - username : "JohnDoe" - email : "hello@example.com" - job : "Window...
I am building a simple web app where one set of users have varying admin privileges who can write to database and the other set can only view data. I am used to securing APIs with JWT or session tokens, but my boss is 50-year-old DBA who thinks it's not secure. He is saying I should implement security within database i...
I'm trying to create repositories in my app. The problem is mainly with 2 entities: Workspace Member a Workspace has many members, while a Member is only related to one Workspace (so a member exists only within a workspace). Workspace has the functionality to add members and check if members exist: class Workspace(pr...
I have a mysql database in which I have drafts, each of which contains exactly 24 players the order of which matters. I am conflicted between having a drafts table with 24 extra columns for each player or creating a new table for a one-to-many relation between drafts and players. Drafts ID Arbitrary info Player1_ID...
According to Should I use a layer between service and repository for a clean architecture - Spring the Peristance layer is deprecated because the Repository is already an abstraction. UML solution of the previous question Product and ProductEntityJPA But, in reality we have to use two entity : One for the domain entit...
I am currently working on a Raspberry Pi based robotics project that I would like to connect to a realtime customized control panel/dashboard, mostly for debugging purposes. I created a test setup where each instance of the robot "operating system" can be seen as a separate device in the dashboard, with a unique sessio...
Default interface methods of C# 8 and extension methods have in common that you can "add" a method with implementation to an interface. "Add" being in quotes here because for extension methods that's not quite precise. Extension methods only associate a method with a type, which makes autocomplete suggest it when you a...
I have a 3 layer architecture application with presentation layer, business layer and data access layer. UI -> BLL -> DAL UI Layer has reference to only BLL and BLL refer only to DAL. My BLL has DTOs used by view and use service class that inject repository class from DAL and map DTOs to specific DAL entities for sendi...
I am trying to create a duration matrix, that is, time spent in each status based on the status transition event logs. I have the following event log where status transition time along with old and new status is being captured. | Event Time  | Old Status | | New Status | | 2022-10-21T21:22:34.419+0530 | NONE | -----> ...
Which paradigm(between OOP and Functional) should be chosen for a given task ? What are the tradeoffs between these two styles ? In which case using Functional makes sense and vice versa,in which case OOP should be used ? we all know, OOP: As the name suggests, when designing a system with object-oriented programming,...
This question is similar to Permissive vs. Strict API Message validation. One difference is that we're using Protobuf. A colleague and I are discussing standard message types for names. One possibility is: message Name { string first_name = 1; string middle_name = 2; string last_name = 3; } Another possibility i...
I am reading through "Clean Architecture: A Craftsman's Guide to Software Structure and Design" and it says that: All race conditions, deadlock conditions, and concurrent update problems are due to mutable variables. Functional programming languages do not allow variables to be mutable. I can see why race conditions an...
I am creating SCSS for the large project, I decided to use BEM methodology. I will have a lot of containers. I have question about BEM and about best practices. My current code: .footer { &__intro { margin-bottom: 5em; } &__menu { display: flex; flex-wrap: wrap; align-items: ...
I am dev manager, managing 8 developers. I am facing a problem that the code review becomes more and more a formality even though we all know the code review is important. We do have code review process but when people don't want to do it they can find the way to circumvent it. I hate to be bossy around, telling my guy...
I'm trying to add specialized functionality to concrete types without adding the functionality directly to the interface of those concrete types. Given a vehicle interface with 3 concrete types. interface Vehicle {} class Car implements Vehicle {} class Motorcycle implements Vehicle {} class Truck implements Vehicle {}...
I have two different connection strings for two different databases. My first database has 2 relational tables: -First table has some default fields,among which average on UI, and some additional fields based on second database that are even displayed in UI and that change based on second database. -Second table has al...
This question has always bothered me I am finally ready to ask it out here. I am creating a hotel reservation app, and I am in the phase of deciding what classes I will have. Among classes such as User, Hotel, and Ticket, I also think whether I should have a HotelList class as well, which would be responsible for holdi...
I have created a small ERP application and the architecture I chose included the Repository pattern and the anemic Domain model and Business logic layer. I was reading Microsoft's guide about microservices here: https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/net-core...
When batch deleting a resource. e.g. deleting all Orders that belong to Customer 99: DELETE /customer/99/order If there are defined business rules1 that prevent Orders that meet specific criteria from being deleted. Such as: Orders that were made in the last 7 days can't be deleted. Given customer 99 has orders tha...
Consider unit testing for a program written in procedural style. Each unit test tests a single function. Consider the following example, in which I use C_i(x) for a condition depending on the argument x and S_i for a statement. def foo(x): if C_1(x): S_1 if C_2(x): S_2 if C_3(x): S_3 if C_4(x): S_4 Ass...
There is a blog post by Eric Lippert where he describes how to define variance. In a general sense, covariance is achieved when the direction of assignment compatibility is preserved. Contravariance is achieved when the direction of assignment compatibility is reversed. Now let's use a C# generic interface as an exampl...
From Wikipedia: Attribute-driven design (also called ADD or Attribute-driven design method) is a methodology to create software architectures that takes into account the quality attributes of the software. Why is Attribute driven design, as described in books such as "Designing Software Architectures: A Practical App...
I need to implement a set of algorithms for data processing. Algorithms do not directly access data, but use a set of basic operations that are placed in a separate class. The following code can be considered as an MWE: class Data { .. } class BasicOperations { void f(Data d) { .. } void g(Data a, Data b) { .. ...
Assume I have a simple system with two (simplified) domains in the backend where the Root aggregates are the following, simplified ones: Product with product_id and description Warehouse with a warehouse_id, warehouse_name and Map<product_id, amount> The system is a modular monolith where each domain is a separate, i...
I am trying to decide on which approach to follow for long running tasks. Web Client (user) story Web client connects to the server (REST API + WebSocket for real-time notifications) Web client POSTs a new resource intensive job request Server publishes the job on a queue Task worker consumes the job and processes it....
I have found myself in the habit of using code like this. class glb: "just for holding globals" args = None # from argparse conf = None # from configparser def main(): ... glb.args = parser.parse_args() glb.conf = loadconf(fn) Assuming there is a case for using globals, I feel that this is a...
I thought I understood Liskov Substitution Principle but then I thought of a case and I wanted to ask the community here if I get it right. So I read somewhere to check if we have violated Liskov or not, amongst other things, we also need to inspect the client code which is using the classes in question. So I have an e...
I have an Entity type, let's say Car for example. There is a Value Object type Tire for it. Each car has a set of tires with certain properties. Sometimes tires are replaced, which is communicated by a Bounded Context via Domain Events. There are some other BCs that record a Read Model of the cars and tires. Now there ...
I found the short article Align the happy path to the left edge quite helpful in improving readability of functions. Briefly, reading down the left edge of the function should step you through the logic of the happy path scenario. Errors and special cases are nested in conditionals, or decanted into separate functions....
I am currently building a sequence diagram for a website to allow customers to make online bookings for a travel agency. If a customer books a flight, he/she can use an online payment method to pay for the ticket. Here the bank is an external party. So can I use bank as an object?