instruction
stringlengths
34
36.1k
We're building a service using DDD, CQRS, & Hexagonal Architecture that allows the user to upload a CSV feed for which every row will be transformed and sent to a third party over HTTP. We have two aggregates: Feed & Delivery. Feed contains original entries from CSV and Delivery contains payload, status, and fail count...
I'm learning the Rational Unified Process (RUP) in a software engineering class. I cannot figure out the difference between business modeling and requirement. In the business modeling step, we need to define the business unit, find business actors, and draw business use cases. In the requirement step, we need to define...
In Python it is very common to see code that uses method chaining, the main difference with code elsewhere is that this is also combined with returning an object of the same type but modified. This approach usually assumes that objects are inmmutable and only new instances are returned. The question is whether that vio...
Git commits contain pointers to their parent commit(s). Is there a reason why they don't also contain pointers to their child commits? I get that there's a problem of data duplication, in that you'd have to update both parent and child commit objects. But apart from that it seems like there'd be an advantage in terms o...
I have a few methods that are used from different class tests. Also, some other common methods are used for preparing the test data. What is the common practice to handle this in tests? Should I handle this like any other case by having either base class or some static class (e.g. Utils.CommonMethod())? I use static cl...
I am trying to migrate to Jetpack DataStore from good ol' SharedPreferences and there is one thing I am struggling to come to terms with and that is the amount/size of the data pulling out of DataStore at once. SharedPreferences were asynchronous and it was usually used in a way that they had one accessor with over exh...
I came across Environment Diagrams,it is described below Whenever Python needs to work with an object, that object is stored in memory; and, additionally, Python also needs a way to associate names with the objects it has stored in memory. And so there will be two important categories of things for us to keep track of...
I am trying to parse a file created by another software, but I cant identify a pattern on how this datetime is saved. There doesnt seem to be any consistency. Programming language of the software is C++, so I already tried the unix/epoch method without success. Maybe someone does recognize a pattern or can give me a hi...
I am writing an application where a user will have a custom config json file. The json is just a dictionary where they define new objects of the exact same type. Here is an example with outfits: 'summer' : {'footwear' : 'flip-flops', 'bottom' : 'shorts', 'top' : 't-shirt'}, 'snow' ...
Consider a card game (something like Magic or Legends of Runeterra) program, with BaseCard, Deck and GameState classes/structs. The way I've conceptualized the relationship between these classes would be something like this: BaseCard.hpp struct GameState; class BaseCard { public: virtual void DoEffect(GameState &g...
I'm planning to port or rewrite an MFC GUI C++ app, to use in a GNU/Linux environment, and hopefully make it cross-platform. The app has few, if any, dependencies other than MFC and the standard C++ library. The thing is, I have very little experience in GUI app programming, and in programming for Windows. My question:...
I have several questions related to CQRS in eventually consistent systems with a need of resilient Command/Event processing. Is it OK to have external/public synchronous Commands (triggered by API, e.g. RequestUserCreation) in conjunction with internal/private asynchronous commands (triggered by events, e.g. SendWelco...
Why learning about Fluent Interfaces, I came across this post which states that using set hints one is mutating the object whereas with is returing a new object. I have seen this pattern first hand while using PySpark (Python API for Apache Spark): # Using "set" to modify exiting object from pyspark.conf import SparkC...
coders. I'm learning C programming language and found out such thing as #define directive that allows us to use symbolic constants (following Brain Kernigan). I know that this directives "insert" literals or expressions right into code. Their purpose, as I understood for now, to get rid of magic numbers in a code. Also...
I have a scenario I am considering, and I don't quite find out what's the best solution with OAuth. Hopefully I can learn good things here. We are company A and we specialize in managing secure text notes. They are company B. Company B has users that access Company B site. Sometimes they authenticate, sometimes they d...
Context Suppose one has a list of algorithms, which each have a multiple run/parameter configurations. Next, one wrote a generic function def get_mdsa_configs(self) -> List[MDSA_config]: that returns an list of all the possible run configurations of an algorithm. However, as you can see it currently returns a list with...
I would like to have a class, let's say a queue, that can be specialized to its behavior. For example, let them be a SafeQueue (which disables IRQs before any access) and a FastQueue (which doesn't). As you see, the vast majority of the common code would be just the queue itself. Please tell me what you think about the...
I am reading this article about using DI inside ASP.NET Core @ https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-6.0 .. but i can not understand its benefit of providing abstraction level. for example without DI, we will have those classes:- public class MyDependency { ...
My system consists of 4 seperate layers. API layer Application layer Infrastructure layer Core layer System is not Domain Driven. It contains no entities with domain logic. All models are anemic. System uses third party SDKs to do CRUD actions on external resources that are not owned or managed by me. Commands and qu...
Objective: Designing a data intensive application(myApp) C++ on Linux/RTOS which runs on a single core cpu, there are also 150 other applications share the same core with high priority than myApp. How the system looks: more than 150 C++ applications share the same cpu core and most of them have high priority than myApp...
I've been looking into the Modular Monolith, especially how it's described by Kamil Gryzbek. From what I understand, the architecture should easily support pulling a single service out from the monolith and running it as a separate process. Lets say we have this starting point: To then pull out a service, we would hav...
Prolog: I have a domain-layer which contains some entity-classes like Customer. I have a application-layer which contains some data transfer object classes like CustomerDto. My Problem: At a presenter (in my presentation-layer) a use case interactor was called like NewCustomerUseCaseInteractor.Execute(new NewCustomerUs...
Say that I have a REST endpoint for a chess server. If I'm not logged in and do a GET on /games I could get all running games like: { running_games: [ ..... ] } but if I'm logged in I could get a different representation for that same endpoint /games, something like: { your_games: { waiting_your_...
I have a question about the general guidance of how to properly mongodb design: Scenario: I have many collection of objects, all uniquely identified by their contract_address, and i want to be able to pull from there when need be. I found this post, but it didn't seem like enough reasoning. so would it make sense to ha...
Let's say we have a class( My_Func_Dec ) that models a 'function header declaration' as it might appear in a .h file. const std::string func1 ( const std::string& arg1_, const std::string& arg2_ ) const ; As we might guess from the pic(see above), My_Func_Dec initializes its internal data by processing(left-->right) ...
I have some REST API endpoints set up to create a blog post. Each blog Post is owned by a user. I have the following routes: /users [GET, POST]: Get a list of all users, POST to this endpoint to create a new user /users/<id> [GET]: Get info for the specified user /users/<id>/posts [GET]: Get all posts for the specified...
I'm looking for a pre-existing or easy-to-build data structure available in Java, which can do these 2 things efficiently: Fetch all the values stored in the collection quickly. Iterate over the data structure to fetch each key and its value. Right now, I'm using a Pair<List, List>. With this, I can Fetch all values...
SituationI have a Single page web app with REST API. When the user logs in, they receive an authorization token. The token which will expire after some time. When the user tries to make a server request, but the authorization token is already expired, I want the user to be forwarded to the login screen. Current Approac...
I'm trying to develop an ASP.NET MVC-application with an additional Web API. To reduce code-duplication, I'd like to share as much code as possible, but with the possibility to differentiate between the two projects if needed. My plan is to create a Shared Class Library that contains: Entity-classes Service-classes Vi...
This seems like a common scenario that someone must have solved by now! I have a setup where a Company may have a set of Default Roles assigned, and Users of that Company should inherit those roles. User may also have additional roles assigned at the user level, or inherited roles removed at the user level. Both Compa...
In the past, when I've used MVC, my model objects were just dumb data containers. Everywhere I read says that in MVVM, models should contain business logic as well as being a data container. Now that my model objects also contain business logic, how do I use them as data containers? For instance: my models as an access...
I am trying to challenge my understanding of DDD by pushing it to the extreme. My question is not about a specific practical use case. Rather my question is an abstract one related to DDD in general. Therefore, I do not have any source code to share but thoughts to discuss. The domain model should be isolated from any ...
I'm trying to make an application in ASP.NET MVC. I'm using AutoMapper for the conversion between entities and ViewModels. In most cases, this works fine, but when I need to add some additional data (f.e. a list of items for a drop-down list), I'm a bit confused about where I should retrieve this data and populate the ...
Scenario I have a system where a user can upload an Excel file which is validated and then used to provide data for the application. There are two distinct operations I need to handle with this file: Validation: On upload, I want to validate report any problems with the file, so that the user can fix it. Some of the v...
not quite sure how to put that into the title, because the issue is a bit specific. Basically, we're using gitflow (slight variation of it) in our application. So, this means we have the following branches master (PROD) uat (STAGING) dev (TEST/QA) We create all our features from dev. The developer creates a PR for th...
I work with csv files that after some steps provide the initial data, and with a database that is derived from this data. The database then is read from and written to in many different ways by the rest of the application, the csv files are then ignored. Therefore the idea arose to make one data application layer for w...
I am reading a book C++ Software Design by Klaus Iglberger. In the book, the author asserts multiple times that recompilation effects of dependent code is extremely bad. For example, The heart of the problem is the direct dependency of all shape classes and functions on the enumeration. Any change to the enumeration r...
I am looking to architect an application that will run on the local network. What we have is: 'n' number of laptops connected to a local network All those laptops will be running that application If one of the application makes an API call to an external network It has to inform all the other laptops running the a...
There are techniques of proving program correctness under all possible cases, but that is a more advanced topic, for a later subject in your curriculum. I always had this doubt: Is it possible to know all possible defects in a program before I write a single line of code? (i.e., How to detect a bug during the design...
I'm writing comment to a function that gets settings from a json file, I found my Github Copilot suggesting it being not a good idea to do so. I've looked into Why are global variables evil? [closed] and see mixed opinion on "bad" or "evil" depending on the circumstances. In this case, is using global dictionary object...
Context My office is currently working on distributed (micro) services, as part of this we obviously have Service Discovery between these services so that they are aware of each others locations (when they need to be). Possible Issue It has been discussed that we could additionally have what I have coined Object Discov...
I'm looking for an elegant way (a design pattern if such exists, not a library) to map two classes that share the same base class, without duplicating the code that maps the properties of the base class. Let's say I have public abstract class RequestBase { public DateTime BornAt { get; set; } } public class Reques...
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...