instruction
stringlengths
34
36.1k
I have been asked to create a Django/Python web app that creates web-based, .pdf and excel reports from a Sage Evolution database. While the sage front-end is still being used. My client essentially wants to create their own "Sage" by only adding the features they need in a web app and hence making the process easier t...
I have 1 api key that has a rate limit 1000req/1min. I would like to somehow use 50% of that limit in service 1 and 50% of that limit in service 2. Let's say they're just 2 separate processes using the same api key. How could I implement distributed rate limiter like that? https://www.jeremydaly.com/throttling-third-p...
One of my web services hits a few hundred thousand visits per day where most of the operations are CRUD and we are thinking to get a cache sitting in front of our SQL database. I have had implemented cache before in some other projects using Redis. Basically, before I touch the database, I see if there's a cached versi...
When coding resharper recommends that if you're to discard or ignore the return of a method, that you use this syntax: _ = TheMethodICouldCareLessAboutTheReturnValue(); I know you could just call it without assignment to _ just the same, so why does the _ as an assignment matter?
Hey Software Engineers Currently we basically have a what I would call "modular monolith". A diagram would likely look something like this: What we want to do in the future is being able to deploy each module independently and move to a microservice environment where every module has its own database. We have a table ...
As the title implies, I would like to know if it is possible to create RESTful web APIs using MVVM architecture? Or we can use just MVC pattern to create web APIs?
When using SCRUM as an agile method for development, the first sprint (at least) will involve planning and requirements gathering, alongside user interactions. When I search sprint backlogs, it usually contains items from the product backlog, such as: Build a login system, Build the home interface, Design a database s...
I have a collection of classes in a SQL database that all share the same structure, and cannot be changed. They are similar to the example below. I am using Entity Framework Core and would like to have one set of code which can handle the crud for each of these tables. I've tried to generically the dto object back to ...
Suppose I have a static JS single-page-app that I want to deploy to production, and there are 4 production servers. I can deploy it to servers 1 & 2, try to test it, and then deploy to servers 3 & 4. I can deploy it to all four servers at once. Which one is more preferable and more common practice? (1) requires stick...
I have seen download managers manage to resume HTTP downloads from where they stopped. How are they able to resume downloads? Is it related to the Accept-Range Header? Or are there other mechanisms that download managers use to identify how much of the file has been downloaded and how much is left to be downloaded?
I looking for the scientific agreed upon definition of 'service' in Microservice/Service-oriented architecture. I found a the definition It logically represents a repeatable business activity with a specified outcome. It is self-contained. It is a black box for its consumers, meaning the consumer does not have t...
Usually, the web server that is serving a page includes the CSRF token inside the HTML. However when I'm using a cross-origin REST API, there is no "initial" page that could include the CSRF token. My idea is to respond with a CSRF token after the user logs in, but I'm not entirely sure if this protects against a CSRF-...
I would like to make an order-system with QR-Codes which is online. How I imagine it to work: A customer visits a restaurant. There is a QR-Code on his table which takes him to a public webpage where he can order the stuff he wants. So my question is: How can I check if the person ordering, is actually sitting in the r...
Vulkan introduces a member .pNext of type void* in all its core structs allowing to create handles. This member purpose is to allow to extend the structure by passing a pointer another one. This is mainly used for extensions, so that the same struct can be extended by two different extensions without any need to modify...
I'm working on moving some of our flags to a 3rd party system but I kinda have a hard time, determining what should be a feature flag and what should remain as authorization permission to a particular user. So wanted to ask, intentionally with less context on the type of flags I'm dealing with since it varies for each ...
I have a grid-based puzzle game, that is based on states. I need an algorithm that can find a solution for each game level. A game level starts in a specific state and ends in a unique, well-known state, so I need to find a path to walk from the start state to the end state. Each object in the game grid can be moved in...
So, a situation's come up at work today while refactoring my codebase. I have two classes that each derive from the same base class. The only significant difference between them is what they do at the beginning - one plays an array of audio files, while another plays just a single file. Each has a different set of audi...
Consider a scenario (in .Net Core world), where a microservice A collects data from external sources and sends this data asynchronously (RabbitMQ) to microservice B (the reporting system) where this data is finally stored and analyzed etc. As A has to reject invalid data from the sources, it therefore must first valida...
My software provides two functional requirements, and I represent them as Do A and Do B in the figure 1 below. At the same time, my software has a non-functional requirement to provide the interface in multiple languages. To the best of my knowledge, non-functional requirements should not be modeled as use cases, howev...
I am trying to find a good way of allowing two objects that are separated by a intermediate object to communicate while keeping the architecture loosely coupled. A solution I have developed is to pass method references to the two objects so that they can communicate with one another without needing to have an explicit ...
In Python projects, if your project spans multiple Python modules and you need to pass some data between the modules, as far as I know, there's 2 main ways: Pass the data as function arguments Create a module that stores all your global variables, and import the module from the modules that need to use it When does i...
Module A contains a gap buffer for manipulating text and some associated methods. Relevant to this question is the dependency on a Module B, used for syntax highlighting of text. Module A also provides a type that wraps its gap buffer with more stuff, and brings in some convenience methods for dealing with syntax highl...
I'm doing alone session with Event Storming for my application that I plan to build with DDD approach later on. Event Storming session is for learning purposes. My application domain logic is rather simple one. The application is called - "Vehicle Maintenance Management System" (VMM System). Below there are some genera...
I made a simple 2-window UI to practice the Observer pattern (which I hopefully managed to implement correctly): a window with some text fields meant for adding a new book to a list another one displaying the list itself, which gets updated automatically when a new book is added I'm confused about the way the relatio...
We have an internal library that does a calculation based on several datapoints. There is a fair bit of data required for the calculation, about 5kB in total. I'd like to make this an API endpoint for easier use across the org. But the calculation is idempotent and does not create any resources. I think this means it s...
I am creating a multiplayer game and was wondering if only the server knows about the actual players in the game, or is this list sent to the clients too? So for example the server knows about each Player's ID and NickName, in a list. Should clients also receive this list? Some potential use cases for this would be: S...
I work for a company that wants an external system built outside of their core system. I can't share an SQL database, and can't store data in their database. So I am forced to maintain my own SQL data that has relationships with the internal data. I am wondering how to handle SQL Foreign Keys and external data (examp...
I want to perform some operations on data class fields before accessing them and I am confused about which approach I should follow. I want to write code so that it makes sense to everyone and follows by experts so I want to know Is it good to make data class fields private and only let them access public fields by per...
We have two exit code code PAM_SUCCESS(0), PAM_AUTH_ERR(7). If we wanna return 0 or 7 when we compared password with our password in following code which code is better that this code ? if (strcmp (expected_password, crypt (password, expected_password)) == 0) retval = PAM_SUCCESS; else retval = PAM_AUTH_ERR; B...
I'm writing the sort of tests which go through a whole user scenario e.g. User clicks "edit profile" User edits their name etc. However, I find myself needing often needing to test small variations on the same workflow. For example (3) could be "User saves changes" or it could be "user cancels changes" etc. It feels ...
Suppose we have a BaseModel, which has a type enum, and derived models with same constructor signatures to each other, whose implementations are like : public DerivedModelJ(Object arg1, ..., Object argN) { super(Types.TypeJ, arg1, ... argN) } Now suppose that, when we use them, we want to hit a method that will retu...
This question might seem like a trivial question. But here it goes. Currently, I'm working with this .NET Core application, an N-tier application consisting of a Vue frontend, business logic layer, and a service layer. It's a medium-sized application with + 50 endpoints that the frontend connects to. From the service l...
I want to apply DDD to a pet project and everything fits perfectly except for one part: aggregates with collections and the need of pagination. I've been researching about how to deal with an aggregate that has a collection of entities that are too many to load in memory and, therefore, pagination is needed. I've found...
I was wondering if there is any downside to using E-Tag cache for every request and response. To be more specific, I'm building a data heavy SPA connected to a Laravel API and the client insists that he should be able to see 200 or 300 results at a glance. Although the data is text-only, it is quite a heavy network loa...
From what books I read on linux system programming, it seems like signals were the primary way to communicate events between processes. They were the gateway into many interesting functionalities, like timers, interrupting sleeping threads, IO events and so forth. When reading books on multithreading and latency contro...
Why I'm writing this question is to get more information and to gain more knowledge for state management and best practices. I have been using NgRx as state management on my angular 11 project everything was fine at least I thought like that. Generally how i implemented state management is in this file format: where f...
This may be a dumb question, but I don't know how to solve this. I am moving from CRUD to Domain-Driven Design with CQRS. I have seen many DDD examples like this. You could find many more on Github. The domain model has methods like changeDetails, addSomething, removeSomething, etc., and the commands could be just like...
I'm currently designing a new online platform where the frontend will be Angular using Angular Universal and the backend will be a sort of Node.js clustered microservices. The question itself is what is the best approach for the microservices: One clustered NestJS API Gateway serving the frontend with REST End points,...
Recently, at the organization I work for, we've been using a static code inspection tool. One of the more interesting findings is that private information, such as passwords, may be stored in the heap where it could potentially be intercepted by an application scanning the heap or perhaps a disk swap. The app being sca...
I want to understand the difference between business capability and subdomain Decomposition for mircorservices. subdomain The subdomain decomposition corresponds to Domain-Driven Design (DDD) subdomains. business capability Define services corresponding to business capabilities. A business capability is a concept fro...
I have a jar file, for example foo.jar. My code contains a lot of libraries (almost 75 jar dependencies). I am not using anything like maven or gradle, I'm just using pure java with pure jar files as dependencies, and I am working on my project in IntelliJ Idea. I used the IDE's artifacts system to turn my code into fo...
I am somewhat new to web development and maybe this question belongs to stackoverflow, but there is a human-interaction component here. Here is the scenario. I am serving some neural network models via an ASGI backend server developed via fastapi and deployed via uvicorn. So far as I am concerned, the server is working...
I have a question and answer trivia game app which randomly picks questions from a database and prompts the user to answer the question correctly. The total number of correct answers, the total number of questions attempted, and the elapsed time for the entire quiz session are recorded. What I need is a formula that wo...
We have unit tests that are running some underlying model. We provide it with some test input, and receive some outputs + floating point scores. What's a good practice from a unit-testing standpoint? Should we place assertions on the floating points themselves, or just check that they are within a good range (i.e. > 0....
In the below figure, a CD shop has CD cupboards, and inside it has shelves. CDs could be rented, and class CD Copy represents the actual CDs that are rented. My question is, should I represent Shelves as aggregation of CD copies or CDs?
I write code in R, and often find myself attempting to optimize the code for better performance. In a given script that tackles a specific problem, I test different code alternatives and compare them to each other with benchmarking. At the end, I select the most performant method. However, I don't know how to document ...
I have designed our in-house hardware testing framework. My goal is to ultimately release the framework into the public domain. Early on, my foremost design criterion was to provide a powerful yet easy-to-use test API for test authors. But I didn't want to neglect the test operators either (since they are normally not ...
I need to design the architecture of a CRM "platform" that integrates 5-6 legacy CRMs. One important feature is to show customer records stored in other CRMs in one single dashboard. The actual records are stored end edited in their own CRM. One question is: should I store a minimal set of information about those recor...
I've got a Window, which gets a viewmodel instance injected into its constructor. The window sets its DataContext to that viewmodel. The viewmodel contains a command to "submit" the window and a command to "cancel" the window. The commands are attached to buttons in the window (via a Binding expression in XAML). The vi...
I'm going through some code from this article about ECS-systems in game programming and trying to understand it, and something I'm seeing a lot is using heap memory in places where it seems like there is no benefit in doing so. Take this as an example: class ECS { public: void someFunction() { archetyp...
As this article explains the way to deal with persistent state in an event log driven architecture is to have some "microservice" subscribed to events and be responsible for maintaining that state, such as tallies of the weight of all green trains in the last 7 days etc. But I'm uncertain about how to implement conditi...
I want to understand the Domain-Driven Design approach, how it works, and what it includes in its Definition. TLDNR What is the mental framework behind DDD? What are the core components of DDD? How are the elements applied? Update I will keep updating this post after the helpful post. If you are like me and want to und...
In a document editor application, is it better to implement the command pattern as a layer on top of the object model, or to deeply integrate it into the object model? If commands are a layer on top, they would manipulate the object model using its regular getters and setters. Pros: Commands are higher level, represen...
I have been working on an application which consists of several cohesive services, Customer, Invoice, PurchaseOrder, Highlight, the application is deployed within a mono repo and each service is packaged within its own directory, in a package by feature arrangement. The application is serverless and each entity (aside ...
Certain OS in it's system requirement doesn't specify anything peculiar like in case of ubuntu it asks only for "2 GHz dual core processor or better". If yes, how does it compares with compiled code(C/C++)? I have heard that code compiled in one machine needn't work on another(even if same no of bits). Can anyone shed...
I've recenlty been greeted by CS8603 - Possible null reference return, which indicates that my code could possibly return null. It's a simple function that looks up an entity in a database by id - if it exists, it returns the entity. If not, it returns null. public TEntity Get(Guid id) { // Returns a TEntity on fin...
In C#, how do I handle critical section with two different "rights of way"? Theoretical use case: imagine a swimming pool (the resource). Many individual swimmers (worker threads A, B, C, and D) can swim into the pool as they feel like to, and its totally OK for multiple swimmers to be in the pool concurrently. However...
I have a C++ library that I'm converting to Python. In the C++ library I have multiple constructors and many different types of conversion functions (think radians to degrees, and different types of coordinate systems). In retrospect, these methods and constructors were rather ad-hoc, and, now after converting these t...
Ive got a boot sequence that needs to check some registry values, they may or may not be present, so each check needs to be wrapped in its own try-except. I try to avoid nesting as I think it can lead to confusion, but what I ended up with was: reg_a = reg_b = True reg_a_val = reg_b_val = None try: hklm = ConnectRe...
Sequence diagrams are used to model use case scenarios i.e., main success scenarios and alternate scenarios. That's what I understand from Craig Larman's book. I understand that it depends a lot on the practitioner. I mean a practitioner may decide not to model unimportant/obvious alternate scenarios etc. Is there any ...
I am developing an application with ASP.NET Core with the ability to dynamically add new libraries that implement the necessary functions. They can be included at the start. I have already written several standard libraries myself. I wanted to use the same logger in the main application and in the pluggable libraries, ...
I have a C# system that reads thousands of messages per minute from a Kafka topic. The messages are filtered and I need to insert the filtered messages into a MSSQL table. A normal insert statement is a too slow and seems to hammer the database with thousands of inserts running at the same time. (Currently using Dapper...
So We're integrating our application with stripe and we have different products There are 2 options : Have stripe as a single source of truth, anytime we need to check the permissions of a user we call a stripe api, get the product and decide accordingly. advantage : single source of truth inconvenience: manipulate s...
I have a value object to hold a user id number as a string. This number has a unique format throughout my domain. So, it's being validated inside the object during instantiation and an exception is thrown if it's not of the correct format. The sample class is given below (all codes are in PHP): class IdentityNumber { ...
Shoutout to David Arno for teaching me about the builder design pattern via this thread! I have since used that pattern althroughout the code base to abstract out creating models from data stores, ready to use in the test cases. See the link to the other question for example on how we're using it. However, model creati...
For a mobile app, we are using the Google APIs for geolocation and geocoding. The basic use case is to find entities within a certain radius (in the range of a couple of kilometers) of each other. Often, due to people being either in high rise urban areas or city outskirts, the location accuracy gets thrown off, and th...
I am going over tutorials regarding class design; in one, a videotape can have multiple copies and each copy can be borrowed by a borrower. Please see figure A: I am trying to understand why the answer in Figure B, which considers copy as an attribute would be wrong. My only guess is that then I could only represent o...
In an event-driven microservice architecture, imagine we have three services: Customer service Order service Item service Each service raises an event with data when something happens and stores only its related transactions. For example, we want to know the customers that placed an order in the 30 min after they reg...
I want to implement gitflow but I have a question. Let's imagine I have release version 1.0.0, it works nicely so I merge it into master. We deploy and it goes to prod. Sadly we didn't notice something terrible that brings prod down so we immediately rollback to version 0.9.0 that works fine. At this point in time we s...
Prompted by Sonar, I am looking to reduce the complexity of a function (one that some might call arrow code). I am loosely familiar with some of the principles of reducing arrow code complexity (flattening, eager returns, guard statements instead of affirmative condition checks), but I doubt that this particular code ...
I'm working on a semi-complex web API, the high level design so far looks like this: |--------| |------------| |------------| | |--| | | | | core | | | | | | | | | | | |--------| | | | | | | contro...
To the best of my knowledge, user stories follow a format such as As a [role], I want to [do] such that [benefit] - (This takes 8 days to develop) Recently in the book Software Engineering by Ian Sommerville, I learned about a different story format such as below Which is broken down into What is the difference bet...
In a project I have the same imports in multiple files. For example: import os import logging import json import time import pathlib and pylint will tell me I have duplicate code. I know that there is a way to disable this message: https://stackoverflow.com/questions/29206482/pylint-duplicate-code-false-positive. Howe...
Assume I have a factory which takes in a series of bytes and outputs a pointer to a newly-created abstract message. Now, I would like to define some extensible, manageable, and clean way to "handle" those various messages without knowing the actual concrete type. To me, this sounded like a great application for the vi...
I am developing a utils data engineering package in python, and for the sake of reusability and readability, I chose the functional programming (FP) approach. Assume a key task of converting data from types a, b, c to type X. I write three functions from_a_to_x, from_b_to_x, and from_c_to_x. Is it a good practice in FP...
I'm using a PostgreSQL database and I want to create an analytics table that has a many-to-one relationship with an analytics_type table where analytics_type_id is the foreign key. The table also has a many-to-one relationship with a user table with user_id as the foreign key. The structure of the analytics table looks...
In State Machine diagrams, in some online resources, the condition is merely drawn on the arrow (the left figure below) and in others similar to right figure, where a choice node is specifically used. Which one of the following is correct UML?
I have always wondered whether public, protected, and private has security implications post compilation. Hypothetically: class Foo { public: int m_Foo; // Completely vulnerable and dangerous protected: int m_Bar; // Possible attack vector from subclasses private: int m_FooBar; // Totally secure ...
We have microservices in separate machines that currently use IP addresses in their configuration to communicate via REST APIs. There are also domain names defined for these machines. Is it a good practice to use IP address for communication or domain names should be used in case IP addresses change? What are the pros ...
I'm currently designing an interface for a container that is supposed to store references of different instances that derived from a common supertype. An analogy of it would be as following: Suppose there is fruit store where people can put different kinds of fruit. The fruit store should provide abilities to retrieve ...
We have a legacy system (app 1) that has millions of records of an object Project. It has ProjectId and OrganizationId columns along with other properties. A recently added service (app 2) gets the same object created again in its database as part of some migration. The new object will be created with slightly differe...
We're building a new feature for an online editor that the user will not edit the document, but will be able to highlight & propose edits on the document. Very similar to google documents' commenting feature, rather than a typical editor. The comments don't change the text of the document contents, but the view is diff...
I would like to devise an algorithm that given: An array of dishes with macronutrient information (proteins, fats and carbohydrates, in grams), constrained to a maximum of around 200 items. A desired macro-nutrient target (proteins, fats, carbohydrates, in grams) would output the same list of dishes, ordered by the b...
When an object creation depends on other objects, it is better to have those objects injected into the constructor of the first object's class (dependency injection). For example: Car car1 = new Car(new Body("body1"), new Motor("motor1"), ...). Instead of having them created into the class' constructors: class Car { ...
I just wonder how do you deal with this scenario. Let's say you have an application that uses configuration files that are loaded right after the application starts. Configuration files store - lets say 100 - configuration parameters. For all clients the application uses the same parameters except one (let it be one fi...
New to design patterns so my question maybe silly. I want to use strategy pattern for returning data from a databases in the same format. Nevertheless it varies the query on the underlying database that collects the data. So I am trying to implement strategy pattern. I don't use an interface but an abstract superclass ...
I have a web app that will be used locally on 2 different site. The program is a Vue web app made with node.js and express, using MySQL database. Due to limitation (no internet in site 1), there is no central server, so the web app will function similarly to a desktop app. However, there is a need to sync the data from...
On website uml-diagrams.org it is mentioned that state machine diagram is a behavior diagram which shows discrete behavior of a part of designed system through finite state transitions. To the best of my knowledge, state charts represent the states of a single object of a certain class. What is meant by part of the sys...
How do you handle migrations to your database after a long period of time? I'm using fluent migrator, and after some months or years, the number of migrations could be (and has been in previous projects) in the hundreds. This is a problem for new SaaS instances that only need to seed from the "latest" version. Currentl...
I know what we mean by cohesion and coupling in software. And generally the best practice is to achieve high cohesion with low coupling. It seems to me though that they are inter-related. I.e. you either end up with low cohesion/high coupling or high cohesion and low coupling. Can we ever end up with high cohesion and ...
My question will be mostly about Linux and contemporary X86 hardware. Clarifying the terms async event based programming: spawning fixed amount of threads and using some user space scheduling mechanism. Usually callbacks are handled in a continuation style, so the callback will be executed in the thread of the consumer...
I have an iOS application that uses the Core Data framework. I'm migrating the application from Objective-C/Swift to TypeScript + React Native. My Core Data configuration uses SQLite as a backend. The application has an existing user base who may be (quite understandably) frustrated if they lose access to all the data ...
Context: I am developing an amateur web application (with Vue.js), made up of components, and when reading about state management, the recommended solution is to use a store that gets updated by the components. Over the last 30 years, I have been reading how using global variables is bad design, and I understand that, ...
My teacher told me that in the entity-control-boundary we need to create a boundary class for each view of mock-up but I can't really understand if this is always true. For example if i have a mock up for a sign up like this Then is a class diagram like this right? Or it's better create only one boundary class called ...
I'm studying design principles, and I have a doubt in package coupling principles. I know that the 'Stable Abstraction Principle' says that a package should be as abstract as stable, and it says that we need to keep concrete packages (which are irresponsible and unstable) at an high level to make changes easier, and ab...
In the following image, regarding a CD shop that rents its music CDs. My question is regarding the correct multiplicity of X. I can think of several possibilities for X: X= 1..1 as each copy of CD can rented by one member only at one time. All copies are assumed to be rented at some point. X= 0..1 as each copy...
Hope this is the right place to post an opinion-based question like this. I'm in the process of converting an aging API monolith to a set of .NET 5/C#-based microservices and working on the code reuse strategy. Of course, this is a hot topic, and there are half a dozen or more different ways of approaching it, but what...
Considering i have a Presenter that updates a ViewModel, and potentially multiple Views updatable from this ViewModel. What would you think about this way to proceed : Somewhere we register the Views as Observers of the : ViewModel implemented as Observable. Therefore the Views will automatically be informed when they ...
I want to create an api based on Node.js and Express.js. This api should return an array of products on /products. To get these products on my node server, I need to call a third party api. However, I don't want to call the third-party API every time a client calls the API I provide, because these products only need to...
I have read the Domain Modeling Made Functional book. In the book, the author model the Order in 3 different states: Unvalidated Validated Priced The 3 states have different properties. But it's functional programming. I find it's hard to implement in Object-oriented programming. Since the 3 states only have differen...