instruction
stringlengths
34
36.1k
I have been reading about the concept but still it doesn't make sense to me. I want to clarify my question by giving an example. First of all, if we have task1 and task2 which have to run in sequence, they call it synchronous. Whereas, if task2 runs before task1 finishes, it is called asynchronous. I came across such d...
I'm having a huge doubt on how to connect the front-end of my application to its back-end. So my application has a single entry point where all requests go. The request is dispatched to a controller, which, in turn, needs to call the logic (the model), which elaborates the data, communicates with the database and retur...
I am building a mobile client app that gathers info about movies/TV shows from a website and displays it in a pretty format. When the user clicks on a show, they are taken to a page with the thumbnail for that show used as the background. This works well for most shows because they have dark thumbnails that contrast we...
Our drawing tool is draw.io. Occassionally I've got to draw flow charts with it. In those flow charts I've got to express parallel processes (very similar to this UML example). Wikipedia says about flow charts: Parallel Mode is represented by two horizontal lines at the beginning or ending of simultaneous operations ...
Context I'm currently developing a notification system with DDD which needs to be able to send the same notification to multiple users. For example, a group of party goers might all be notified about the lineup of a certain festival. To accommodate this I've created two domain classes (which are on their own seperate a...
We have a bunch of microservices written in different programming languages. These all communicate with each other over RabbitMQ(AMQP) middleware. There are consumers and publishers in each microservice which listen to incomming messages and publish on a RabbitMQ exchange respectively. The current architecture is shown...
There are times when I have to fix/update records on a Production and/or Staging environment for a Web App. These are remote DBs. Rather than push application code to fix the data, I've been "interfacing" my localhost's version of the running app with the remote DBs. I can do this by simply changing an ENV var for the ...
I have an event driven architecutre, with many microserver that publish a lot of message in my event bus. In some case i can't track why some process is blocked, maybe because my Service-A haven't publish the message in the bus after the transaction saved or maybe the other Servics-B is crash immediately after have tak...
I've question about the philosophy of createMemento() in Originator class in Memento Pattern. My teacher said: now that Originator class no longer stores Memento objects internally, we should give it two new methods; createMemento() and setMemento(). The createMemento() method stores the current state of the Originato...
I have been designing a C++ class that maps an integer to an integer using a vector. Because there is a lot of repetitive data (for example 11115555666222), I am using a compression scheme where I am keeping the struct in a vector that holds the value along with a number indicating where the next value in the sequence ...
First-time poster so please be gentle :) I have a rather large table in my database (MySQL in case it matters) that holds lat/lng values of certain points of interest around the world (table name: Maps). The table is very large (millions of rows) and could grow significantly larger since users can add rows to it. I hav...
I got the following interview question: Say the company has this event, where we will create a button on a website and only the first ten clicks will be accepted and win a prize. Assume that there a millions of people around the world participating in this event. How would you implement it? My answer: Just save ever...
I want to design a domain model for the following system: a customer asks a hotel for rooms availability and prices on a date the hotel send several offers: room type x, price Y, etc the customer accepts an offer and makes a reservation. One way of looking at it is that a reservation it's just an offer "flagged" as a...
I have a shop system that is based on a MySQL database and over which I have full control. On this system runs my synchronization plugin. And then there is an external CRM system with a fixed API. This API allows reading and writing of customers. When reading, I can specify a UTC timestamp and it will provide me with a...
Let's say we are building a threaded program in C, for example a message queue system where a thread is spawned to manage one end of the queue, and (re)connect sockets. This can roughly be set up in two ways (excuse the pseudocode): void spawn_thrd(){ struct S* = **allocate new structures for thread creature** ...
I am just getting into DDD, and I am trying to model a very basic exercise schedule. I have a Schedule and I have a Slot the slot takes 0 - many Exercise entities. The schedule is composed of Slots which must be a minimum of 7 to match up to a week but I don't want to prevent users from having a schedule that exceeds a...
I'm reading SICP, and I don't understand how Lamé's Theorem gives us an estimate for the order-of-growth of Euclid's algorithm (the relevant passage is below). It would make sense to me if the assertion was that the smaller of the two inputs grows as the logarithm (to the base phi) of k. Intuitively, it makes sense to ...
I am looking out for a general design strategy or pattern designing various components in my client application. Here are high level details: The data is accessed my making a RestAPI call. The data returned by making a single RestAPI call is called a entity. This entity is de-normalized data meaning, if there is a Use...
I'm designing the architecture of my application and I'm running into an issue. For the webshop every Order entity has a relationship with a Store and many StoreItem's. This allows for quick fetching of information when a user wants to view the Order. However, when a StoreItem is altered, or even worse, deleted, this i...
My project is about an automatic HTML documentation generator. The final product can't be in C# because of some organizational and legal constraints. To my experience, Python is harder to debug than C#, primarily because it is only weakly typed. Hence I thought I could implement my project in C# and then convert it to ...
I am teaching a beginners course on JavaScript programming and web development. Passing a function as a value into another function is a very common thing in JS from the very beginning. As the students are total beginners untouched by programming concepts, I need to be very careful and thorough when explaining abstract...
We are working on a multi-tenant SaaS product that has a ledger of all tenant customer transactions, which we use to track invoice states on a line-item level. This particular application will result in a lot of upstream interactions with service providers which results in a lot of line-item debits and credits. The poi...
I own a library that reads a file (large or small) and converts it to a special format that one of our vendor's application needs. This conversion can take anywhere between 5 seconds to 10 minutes depending on the file size. Until now, when my users wanted to use this capability, they needed to integrate my library int...
To clarify, I'm having to develop a GUI application that stores information about clients (for a course) where one of the fields is the logo of the client. I'm currently using serialization to persist the information, but in Java BufferedImage cannot be Serialized. I also cannot merely save the path since this could ch...
We recently integrated a monitoring solution (Data Dog) for our REST-APIs based microservices. The monitoring solution gives us many useful metrics. For example, we can see the average response time for each API. It also alerts us if the average response time increases for a specified period etc. However, we recently s...
In a project I am working on we load various entities from the database, do some work then attempt to save the resulting entities. If saving the result is not successful, we return a Result object containing any errors. If it is successful, we return Success = true & Messages = new string[0] and don't use it ever again...
According to documentation from PM: https://pm2.io/docs/runtime/guide/load-balancing/ To make use of its load balancing feature which uses node's clustering to spawn multiple node processes, I need a stateless nodejs application. In the context of clustering, you first need to be sure that your application has no inte...
I'm currently working on a game in which a maths module is being used, here is one of the classes called Vertex. I'm getting confused with the relationship between HAS-A and objects representation. I know that HAS-A is the composition of the object, but what has the composition got to do with the objects representation...
I have a project that relies on getting data from IoT devices. then I display the data analytics using a graph (in real-time) and also the state of the machines (are they working or not and the reason for stopping ... etc). something like https://evocon.com/ The important thing is that I decided to use Apache Kafka bec...
I came across this question and super confused about rethrowing concept in the following example: try { // code that may throw exceptions } catch(Exception ex) { // add error logging here throw; } Above after error logging, the same exception is thrown again. I don't understand this. I summarized my ...
I recently ran an Event Storming session and a scenario came up where we needed to represent a loop within the process. The events and commands needed to happen iteratively until a condition is meant in order for the process to continue to the next event. Representing the command and event only once in a linear line al...
How domain model capture business logic / domain logic since i cannot access repository? I see many posts saying that domain model = business objects But Business objects live in application layer (service layer "not domain services") where they constructed after a repository call and returned to the view if that is tr...
I'm currently trying to implement an event-system following a broadcast/observer scheme. I have events/notifications that contain information about what is happening: class Event { public: Event(const std::string& _name="event"); ~Event() = default; protected: std::string name; }; /* I want to flexibly ex...
Say we have to create a model for a company, where employees can be part of many different teams. A team can have member members. Members can be part of many teams. How to design database tables for this is well known, but what would be a good model for this in the world of classes? Both Team and Member have their own ...
I am at my company for half a year now and think that I have gotten a fair idea of their codebase. Initially I didn't dare to form strong opinions, but now I start to feel that the code could benefit from a more structure and more software engineering. My coworkers do a great job of adding new features, creating a cool...
Assume a device using Raspberry Pi to control some hardware. This diagram tries to clarify the components: SOA concept feasibility is being explored right now. The motivations are: Components in different programming languages Need for maintainable components Need to support desktop, phone, etc. ... Would the SOA co...
Context: I am talking about a new program from Microsoft for Microsoft Teams based app development called "SLATE". This program requires 6 weeks fixed timeline for the "Build" phase and 2 weeks fixed timeline for "Envision" phase. Microsoft development partners who are involved in these phases, need to provide detailed...
I've been using different ad-hoc variations on this, especially in numpy / pandas / data science-y applications. For example let's say I've done some intensive processing that outputs a numpy array and there's probably no need to redo that part of the code. While debugging I want to rerun the script but avoid that pro...
I have an Unity project with countless of C# script files and I'm working on it solely. Although nobody else is working on it, I'm aware that some form of code documentation is crucial for my future self. What I thought about is putting comment files like these into each file / class at the top for a better overview: /...
There are many secured applications developed in node.js. However, I could not find any framework (like Spring-security in Java) that can be used to save the trouble of managing the authentication (login/logout). Going further, there are many flows like create-account, forgot-password, change password etc. that each ap...
I am in the process of implementing a visual programming language similar to Blender's node editor or Unreal Engine Blueprints. It will be implemented as a SPA that will communicate with a JSON based REST API. I am trying to represent a graph similar to this in JSON: +------+ |Number| | Value|-----+ +----------+ +----...
I'm using C# with NUnit. Let's say you have a class public class MyClass { private int classMember; [Test] public void Test1() { classMember = 1; Assert.That(classMember == 1); } [Test] public void Test2() { classMember = 2; Assert.That(classMember == 2); ...
Consider we have something like this: A person, which has a physical body with arms, each arm has a hand, each hand fingers, and each finger a fingernail. Another example: we have a car and a car-wheel in it. So now I want to tune the fingernail a little bit, or the car-wheel, in both cases I want to change the color. ...
I will have to create a second app based on the first app. The second app shares 98% of the code (Some of the UI is different). I am wondering how to set up the second app without creating a merging hell. The files which are different are not in one place throughout the code tree. (The app is a flutter app - I don't th...
Given a Set of messages sent to a Queue, what are good ways to determine all of the messages have been processed? Constraints: Large number of messages Other messages besides those in the Set will be in the queue (queue size may never be 0) Queue does not guarantee ordering of messages The best solution I have though...
We are currently making the codebase for our company. In this project we upload user data like users ID card, drive license, bills for identity confirmation and a lot of other sensitive data. My question is why we should use a server that only helps with authentication when we already have to deal with the user data? F...
I have a task of designing login system with the requirement below: If the user login over three times, lock account for the first 5 minutes. The next failed 3 times login-in will lock the user account for good. Only the admin can unlock the account The way i am design the system is that I create 3 more columns in the ...
My application deals with multiple entities (Articles, Files, Images, Documents, ...) and multiple Users (another entity). Every entity must have one or more "Author" User(s) associated to it. First design Build a many-to-many relation between each entity table and the User table. Articles <--> Articles_Users <--> User...
I was reading about it and was thinking surely the queue first in first out system would make more sense than using a stack because the last instruction will become the first right because it's lifo?
I am looking into Eric Lippert's answer to this Stack Overflow question. In his answer, he uses the phrase "lock ordering inversions" in regard to deadlocks. I've searched the web and have come across priority inversion. Is this the same concept? If not, what exactly is lock ordering inversion?
"Transactional outbox" is a pattern for distributed systems which makes use of a single db transaction to do both, persist changes to the domain model and send a domain event message to the outbox. In my understanding, being responsible for updating the domain model and sending out domain events are two quite separate ...
I have a function in python that calls itself recursively, and has some internal variables passed down the recursion using keyword arguments (that are not listed in the docstring) Is it a problem to have this exposed to an user instead of defining another private recursive function that is called by a public function. ...
Question about the 12 factor principles and, specifically, the dependencies step: https://12factor.net/dependencies From how I read this, the general idea is that you want code that doesn't rely on system wide packages (so centralized libraries following a DRY principle is what I gather) and those dependencies should b...
So let's take the Facebook Messenger app for example. When you send a message it instantly gets sent to the other user you are writing to.I believe they use some kind of WebSockets to send these messages (correct me if I'm wrong). But when the other user closes the app, does he still receive the message? Does Messenger...
I am trying to give examples of a use case and a scenario for a library management software system, I was reading this question: Difference between scenario and use-case and I got confused. Namely, in the scenario section put the following: A student looking for supplementary material about a subject comes asking for...
I'm on the way to build a modular Java web project with some pluggable modules - like Jira and Confluence for example. My first thought was to build a project with Spring and OSGi, I started finding a workable OSGi framework that can suit Spring. It led me to Spring Dynamic Module (SDM) and Gemini Blueprint (GB). SDM i...
I would like to create GUI + API that calls third party API as follows: third party API is consumed once a day by my API, GUI user doesn’t have to log in every day (eg. can log in only once every 30 days to request data from my API) design my API scalable The flow of system: desktop/browser GUI sends request with 3r...
I would love to hear some more expert opinions on a problem related to bulk real time information, here some details: Use Case The users view in real time a map with determined places. The users can create a post if they find themselves in that place (via geolocation) Posts for a place will get removed after some time...
A few alternative twists on the question title to contextualize further: What to archive of the "sources" for a given software build? Should I include all transitive packages in my repository? Is it OK to rely on the package manager to be able to reproduce a build at all? Should I archive a ZIP file of my git repo rel...
Suppose that we have a Post resource (this is just a dummy example): GET /api/posts/1 { "id": 1, "header": null, "content": null } And now we'd like to create a Header inside the Post#1. POST /api/posts/1/header { "color": "blue", "title": "Some title" } Now, is it okay for the POST request above to return ...
In my application, we record audio of people speaking, send this to a speech-to-text (STT) service, and present the text to the user for editing. Simplifying a bit, the STT service returns results in the form of a long list of words with timings: "words": [ { "value": "Today", "from": ...
In open source projects handling user data in a secure manner can be managed, for example through encryption and password protected functionality. What I'd like to create is a way for the user to publish content, which can be read by other users, but not manipulated. In case a program has some safeguards against temper...
One big customer asked me to supply my program to run within a balanced VM-images structure; I mean, the program will be recorded into an image which will be launched in "instances" to process a huge amount of data. So, we will have the same "image" running sometimes in 10 VM's (instances), sometimes in 100 VM. My soft...
My application is deployed on several servers that all read data from a single database. Following safe deployment practices, code deployments happen first on a subset of servers and only continue to the remaining servers if no issues are detected. I'd like to also employ safe deployment practices for some critical dat...
Assume that there is a question where a string needs to be passed. Some modification needs to be done on the string and then returned back. For the programming languages like C where a string is a character array, making the modifications, swapping characters is not a problem as all of them can be done in place. But fo...
In a C# console application of mine (which uses CliFx for the command line processing), I'm setting up dependency injection using Autofac. What I've learned about IoC is that you should have a single composition root with all of your types known and registered there. I'll be honest, the idea of having a single location...
The issue at hand is that I don't want to repeatedly hit the DB to look up user information for the logged in user over the course of the many requests made within a single session. My first inclination is to use Session Scoped Dependency Injection, however this isn't possible with out of the box DI features provided b...
I want to create a little todo app, with a "pedagogic focus" on clean software design. I spent some time reading about design patterns lately and I am trying to wrap my mind about which of them I could and should use. Features I want my "todo items" to provide: Timing has a due date has a due date and due time is "ti...
I have an Exam class that represents an examination/test: public class Exam { public int Id { get; set; } [Required] [StringLength(maximumLength: 30, MinimumLength = 1] public string Name { get; set; } [Required] public Subject Subject { get; init; } [Required] public Enrollment En...
In JS, code runs single-threaded, that's why asynchronicity is necessary. I cannot use code like result = someRequest(), instead I need to give it a callback someRequest(resultCallback) or write a Promise result = await someRequest(). But why was the language designed like this? Wouldn't it be much simpler if everythin...
In other words, should the raising of an HTTP 4xx code be considered an error, and should the job of sending an HTTP 4xx code to a client be delegated to an error handler? Or is it simpler to just send such codes from whichever local code block we happen to be in, when the need arises, instead of delegating this to an ...
Suppose I have data that easily fits in memory in a redis database. The redis server runs as a single service on a single process on a single machine. Let's say I have a 100 different machines connect to it often for various reasons. What benefits would I get by having "a cluster of redis nodes" as opposed to just the ...
I'm working on a rich client desktop application. I'm trying to use MVC to decouple the model, view and controller responsabilities. Problem is I can't seem to find a clean solution for handling communication between nested components. Most of the answers I've read online were either confusing or were dealing with "web...
There exists different composition arts/techniques, i will present in the following some of them. The question then is do you know more techniques additional to my presented ones? And then the important question is, what kind of different makes it from the client perspective, how should i access from a client a composi...
I have some logic that needs to be called by multiple applications ( mobile, web, ...). Instead of duplicating this logic, I thought of putting it in a Rest API so that I could call it from any of the applications. The "logic" that I wish to put on my Rest API basically reads, creates and deletes multiple rows from mul...
So now i have a really concrete example; its highly related to that question here: Tell one, but ask the others? the important statements there are: In the comment section https://softwareengineering.stackexchange.com/a/418453/347781 : But what you would say if both sides pull out the data?, ok i put the behaviour to...
I am working on a program that needs to work on floating point values that are fetched from different database types: currently we support 12 different DBMS (for example, two of them are Sqlite3 and MariaDB). My code applies some business logic to the values fetched from the database, a floating point score is calculat...
I am in the process of developing some software using CQRS, ES and DDD. A part of the system is writing services for controlling devices and collecting data from them. Consider a "Start" command coming from a user interface. The success of this command depends on the execution of the start() command on the device API i...
I'm looking for a way to share a React Native component with 3rd parties without having to share the actual source code. Something like a .jar in Java or a .dll for C#. So assuming we have company A and company B, i (as company B) am looking for a way to provide a react native library to company A without being able t...
Suppose we have a project consisting of many microservices, all of which use a common library. The common library has been put into a separate git repository, and each microservice is also in its own individual git repository. When the time comes to make a change to the common library, how should that be done? Because ...
Let's assume we have a use case where ServiceA needs to make several calls to ServiceB. I know it would be best if the calls could be consolidated as one request, but let's say that's just not possible for this use case. My question is who should be concerned with not overloading ServiceB? Should ServiceA trust that ...
Hello Fellow Programmers, We are converting our monolithic application into microservice based. One challenge which we are facing is that one of our component is stateful. We cannot make this component stateless as of now (Due to high migration cost) so we have decided to horizontally scale this particular component on...
Consider an interface: interface Auth { fun doAuth() } this can be implemented for multiple APIs: class GoogleAuth : Auth { override fun doAuth(){ throw NoGoogleAuthImpl(); } } class TwitterAuth : Auth { override fun doAuth(){ throw NoTwitterAuthImpl(); } } Now, a class might want to use one Auth ...
I have just a few tenants on my application right now, but the number is going to increase over time. The processing logic for each tenant is slightly different from each other and right now the logic for each tenant is residing in the same microservice. From a best practice viewpoint, is it a good idea to create an in...
I am building an API for webshop. I need to implement following scenario: There are x (let's say 500) digital items, which will have same price (let's say each item costs 10$), but unique serial number. There will be a sale on specific date. I need to prepare for "optimistic" scenario, where there will be more than x (...
Are there best practices about how to prepare lightweight viewmodels with dummy data, that could be used in SwiftUI previews? Right now, I have a viewmodel for an in-app purchase screen, that needs to fetch products from the app store, but for mocking it in preview (without needing a whole fetching code), I added secon...
v = |x1-x2| with 0<=xj<=C for j=1,2, C constant I was trying to moel this relation by linear constraints. This is what I've done equality is equivalente to superior and inferior relation. begining with v>=|x1-x2| : this "superior" relation can be modeled as follow: v>=x1-x2 (I) v>=x2-x1 (II) for v<=|x1-x2| : this "infe...
We have a Spring-Boot Web application currently deployed to 7 environments (DEV, SIT, UAT, Pre-Prod, Prod, etc.). This application connects to other REST services, which has different URLs for each of 7 environments and are maintained in environment specific property file for our application. We are planning to reduce ...
I have a lot of classes that are just a CRUD interface for microservices. They only have a param for the endpoint and some of the methods get_list / get_item / create / update / delete / activate / deactivate. To be DRY, the methods that are necessary for the microservice calls are all grouped in a BaseAPI class. A sma...
I'm a little confused about how to handle cookies between frontend and backend. I have a frontend react application a backend node express application. The frontend is hosted on Netlify and the backend on Heroku. It seems that you cannot put these apps on the same domain- www.mydomain.com (not sure if correct). So in...
I was going through https://docs.microsoft.com/en-us/azure/architecture/patterns/choreography, the document mentions in the drawbacks of having a central orchestrator that it can become a performance bottleneck. This is something I didn't get, because even if we move towards the choreography pattern as described, any w...
I have read in a DDD book that using message queues between communicating services can make the whole architecture more scalable, amazon's documentation mentions that queues provide granular scalability. I don't see how it is 'more' scalable than services communicating synchronously using http. I agree that it scales m...
I'm building a forum application using the Django web framework but I'm not sure how to design the entity relationship diagram when it comes to the Post model. Since one Post can have many replies, should I model the replies as Post objects so that there is a 1 to many relationship on the same model(Post model in this ...
I'm creating a .Net 5 API backend and use EF Core for the database part. The simple CRUD way I know: API layer calling a command or query from the application layer using MediatR Application layer calling CRUD actions from repository interfaces As we all know the CRUD actions are struggling with the real world proble...
I am trying to work out the best practice for structuring a series of Azure durable functions for reuse across future development work within my organisation. From the doc's it seems like the desired approach is to setup single use activity functions, and then reuse them within different orchestrations, but what is the...
I am trying to come up with an algorithm that generates every possible combination of Scrabble tile sequence on a player’s rack. I want the sequence to be comprised of n number of indices depending on the number of tiles on a player’s rack. So for example, in Scrabble, a player MUST have at least 1 tile on his rack but...
I have a notifications app which sends users notifications. It uses a .NET core backend, an angular frontend and Cosmos DB. Within this I have an API endpoint function which is linked to a button used to clean up inactive users' records from the DB based on a selected time period. This database job takes a long time to...
I've had a question for a while. I know that the Array prototype method filter is generally preferred over forEach, and I believe it is typically faster at the job as well. But what about if I have an array and I'm trying to partition each element into either bucket A or bucket B. Say array elements with property P ar...
I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm following Hexagonal Architecture. So, I came up to the conclusion that i should check if the User really belongs to the Company...
I'm working with a codebase that is almost 4y old, just a little under 2000 source files and roughly 100 developers have committed to it. One of our third-party dependencies is not actively maintained anymore and we suspect that it will no longer work as we keep upgrading our stack. We would like to estimate how much e...