instruction
stringlengths
34
36.1k
From official documentation: A "middleware" is a function that works with every request before it is processed by any specific path operation. And also with every response before returning it. But I would like to ask what is the point of a middleware in FASTapi? What problems does it solve? Can you please provide me a ...
Consider the following Typescript code: function exampleAction(target: Target, options: ExampleActionOptions) { // ... } export function getExampleAction(options: ExampleActionOptions) { return (target: Target) => exampleAction(target, options); } Here we have two functions. One that has the actual implementatio...
I'm here for some advice about how to manage the situation where I have a legacy application running locally on an onpremise server with it's own database and I'm about to add an online shop app to it. I have created a new domain model for the context and added an anti corruption layer (ACL) to convert the data. This A...
With Java record being immutable, I don't know how to use them properly in the context of something like a CRUD application. If we take a very simple example of a "Organization" record: public record Organization(String id, String name){} This looks good, its immutable and has all the good stuff built into it. Now, le...
apologies, if my question is to trivial. But i after doing some research i couldn't find an appropriate answer to this seemingly simple question. As a developer with some experience, i know that i just could "code it down". But i'd like to create REST sharp library, that is easy to understand, maintainable and testable...
I'm currently working on an ERP Blazor WebAssembly app that works alongside its base Razor Class libraries. The app could have some custom pages that aren't the same for all the customers and are independent (that means that the core app remains the same while the custom pages could get modified). I've tried putting a ...
In my python codebase I have several open source dependencies, eg. pandas, plotly, etc. Some of these are missing some functions that I'd rather they have. I sometimes add functions to these libraries after importing them because it seems better to me to keep some tightly coupled functions in the same namespace. To giv...
I have a (php) program, which must change yearly. This program calculates tax for every year and there are sometime changes in requirements. First, the user fills their incomes, expenses, etc. Then clicks the download button, which creates an xml file for him. The Download class use Calculator classes to calculate the ...
I am creating a UML state diagram to help me plan the card game simulator I'm working on. At the moment I'm stuck on an issue where actions that can be performed from the "Main" state, the state where the game is simply waiting on the player to choose the next move, or as a result of the effect of a card. For example: ...
I'm developing an app that will work as a troubleshooter. In this, I want to ask the customers only relevant questions instead of giving them an exhaustive list. Every option they choose will have to be linked to a new question with only a few answers, so I can distill the issue they are having effectively and without ...
I'm thinking about a rewrite of a existing application. This legacy application does not separate frontend and backend. It's a single application with server side rendering. I want to rewrite it to a separate backend that provides a restful API and a frontend. Right now I plan to use Node.js with Express and tsoa as ba...
If all data is essentially just a bit string, then all data can be represented as a number. Because a compression algorithm, c(x), must reduce or keep the same length of the input, then the compressed file must be smaller or equal to the input (and greater or equal to 0). This can be stated as 0 <= c(x) <= x. For compr...
We are developing Word Addins that interact with elements in Word documents. To make it testable, my approach has been to use interfaces and wrappers for UI elements, and then provide mock alternative implementations to the wrappers. For example, IDocument wraps a COM Document object and provides accessors to the relev...
We have a very messy data repository component, with dozens of methods to interface a DbContext (entire database) in Entity Framework. It was (and is) coded in a way that adds a new repo method for each table combination a query needs to run on/return. For example: GetEmployees(), returning something like DbContext.Em...
Is it code smell to make an abstract child class implement a method, which overrides a parent method, whose only purpose is to call another abstract method? I want to make sure that anyone who implements my abstract class is aware that there needs to be special handling to override the functionality of a parent method....
I've been a heavy user of "batch jobs" to perform different kinds of logic in systems. Over the last couple of weeks, I've been thinking and reading about other approaches and I wanted to bounce some of my ideas and get some feedback and trips. So to set the stage, let's look at a use case: We're creating a chat applic...
Our organization is into Health Care RCM business. In that, we use to receive medical records (called as accounts, which is a business phrase) and our staff (Medical coders) use to do medical coding, based on the accounts received. On daily basis, accounts will be receiving in a high volume from multiple clients and th...
I would like to know more about the Specification Pattern, as it is described in Eric Evan's book "Domain Driven Design". One of the key points Evans makes is that the domain model contains all important business rules (logic and behavior). The DDD tactical patterns in the book describe how domain knowledge can be enca...
Assume you have to figure out a dynamic way where the user can provide an API call to hit in the backend for example, user to provide a webhook to call on his end server So, An idea for users to provide a CURL command in UI would be an ideal way to cover all cases such as request method types, authorization, params... ...
I'm pretty new to Github and I have one question I couldn't really find a clear answer for it. Let's say I have a project called "Practice". In this project I would like to create different web components and practice my skills. Should I group all the components inside a single repo called "practice-components" (github...
During the course of my load testing journey, I'm doing mostly spike test on the SUT(System Under Test). We gradually dial up the number of users hitting the server, from 10, 100, 1000. And we log the process execution time separately from the response time, and these are the kind of results we obtain say for a spike o...
In the case of kotlin, rust and many other programming languages... There are variables with direct implicit type declarations... Where you can see the type of a variable at the same line where it's defined and initialized. val a = 1 if you change this code to this... val a = 1.5f the change can be easily addressed d...
I have the following problem, I am implementing a delivery management service and a single order can be competed between N deliveryboys, this service is being executed on Kubernetes with 5 PODs of this application. When a deliveryboy clicks on the APP to accept the order for delivery, this flow must be synchronous to r...
For compliance reasons, we want admins of a web app to work on it from devices (phones or computers) approved by IT. Or rather, they can work from other devices, but should get logged out quickly, so they won't forget an open session someone else can use. We want to minimize both false positives (sessions on untrusted ...
I am thinking how to develop an application in a DDD way, and now I am thinking about the concurrency part. In some examples I have seen that in the domain classes are injected with dependency injection an implementation of the repository, and also in the root aggregate is added a field version, to control the concurre...
When I am using the classical style of unit testing, how do I keep the number of test cases for an object that has many collaborators from growing too large? And how do I keep the setup of each test case from growing too large? In Unit Testing Principles, Practises, and Patterns, Vladimir Khorikov recommends I use the ...
I’m currently tackling a programming challenge to schedule a series of “performances” (a set of dancers together on a stage for a period of time, concretely) that each involve a set of “participants” (the set of dancers who form the group for a performance). Each performance involves some subset of all the participants...
There are two schools of thought on how unit tests should be written. The first is the Classical/Chicago school, which focuses on the isolation of unit tests, describes a unit as a class or set of classes, and allows test doubles for shared dependencies. This school lends to the Inside-Out style of development, where t...
I've studied how data transfer with secondary storage(HDD or SSD) works. Would you mind to check that my understanding is correct? File system block is basic read/write logical unit which is used in file system OS page for memory management is different from block OS page size might be equal to block size or not, but ...
Suppose I have some Java code such as the following (in this case, the use of the name "interaction" is referring to interacting with an object in a video game): public abstract class Interaction { private Interaction() { // ... } // base class stuff here, some public some private public s...
Another name for this question could be: How to TDD the main function? My situation: I'm writing a program from scratch that runs a sort of simulation, and I want to apply TDD to the whole development process. It seems straightforward to me when I think about the small detailed features, but at some point the program n...
I have a similar situation to the user here How to design a database wherein multiple tags(string) are to be associated with an id? However I'm designing a system where each association (between article and tag) is per user: User Article Tag Robin <URL 1> tag1 Robin <URL 1> tag2 Robin <URL 2> tag2 Alex <U...
Hello StackExchange community, I'm in a bit of an impasse for my current project. The software in question is a collaborative program designed to let employees work together on the platform and assign tasks to each other, that can be further split down into subtasks, as far down as the company would like to divide the ...
I am wondering if serialization and deserialization of classes should always be treated as an "atomic transaction?" What I mean is, if an error were to occur during the process of serializing or deserializing a member of an object, should the whole serialization/deserialization of the object be considered to have faile...
I am working on an API that has a User resource to represent the current user and a User service that handles business logic for representations of this user. I need to introduce an Organization resource that has Members, which are effectively Users within an organization. I need to build a resource that is represented...
We have a system with a few microservices and multiple clients (Web, mobile). Currently, only one microservice (let's call it "Master MS") exposes a public API, which is used by all clients. This worked well until now: Master MS did occasionally ask for data from other microservices, aggregated it, and sent to clients....
I was reading a post about testing in SwiftUI and the author said that don't write unit tests for your View Models that tests the UI of your view. The example he gave was a simple counter app. class CounterViewModel: ObservableObject { @Published var count: Int = 0 func increment() { count ...
We plan our sprint capacity in story points - so for example we have 20 points available when planning a sprint. When we have stories which were not completed in the previous sprint, we generally roll them over. But what was originally a 5 point story might be almost complete. If we simply move it across then it takes ...
The idea is that if an app I like periodically has noticeable bugs or issues, and it’s commercial, not open source (in this case, AirBNB, but I feel this way often towards many apps), I would like to actually help them fix the bugs so the tool I rely on gets better and I don’t have to face malfunctions. I could observe...
If you solve a bug in a poor way, it might result in even more bugs in the future, so I need a way to validate if the fix was actually good. Time between the bug assignment and issue closed doesn't seem right, so I'm not really sure what metric to use (if there's even one). Measure code complexity after the bug was fix...
In UML sequence diagrams, there is the possibility to specify a synchronous call with a reply message. Example (taken from https://en.wikipedia.org/wiki/Sequence_diagram) When modelling that in mermaid-js, it renders "OKish": However, the syntax is "strange" (because, for the reply, it uses is the notation for asynch...
Github Copilot got update yesterday (2023 St. Valentine) https://github.blog/2023-02-14-github-copilot-now-has-a-better-ai-model-and-new-capabilities/ but still no information for its use in the business software evolution. AFAK Copilot is good for generating code snippets for the general problems. https://www.reddit.c...
I'm modelling a scheduling application and wonder how it could be avoided to update multiple aggregate roots (AR) in one transaction. I understand the fundamental problem of changing multiple ARs in one transaction, since it could cause a lot of conflicts. However, I don't see an alternative in my case. The schedule lo...
Outline of the current architecture of our web app outlining the issue I'm seeing Client-side app is React, talking to a server running the Play! framework via an API. On the page is a table that allows a user to select 0 to many rows via checkboxes. There are buttons above the table that allow the user to take bulk ac...
Thinking in the classic example of orders and lines. I would like to use the domain classes in the presentation layer, so as to check if an action or a property is correct, the main code is in the domain classes and I only need to adapt the specific aspects for the UI, for example, nulls, that in the domain it common d...
I have a lot of classes that have numeric values that are configurable by the customer during runtime and should be clamped between a min and a maximum value. The value changes should also be logged. An example of this is given below: public class MyClass { public double AMin { get; set; } public double AMax {...
I'm creating a language parser on a microprocessor in C++. For the tables of keywords and commands, rather than maintaining a single curated file (alphabetically sorted, etc), I'd prefer to declare them in the header files for each set of functions (ie, unsorted). Then, I can have the makefile run a program to scan t...
So this is a topic I have never really tackled, so bare with me as I try to describe my issue and the scenario. I have an API endpoint in my service that sends emails to a bunch of users. The set of users selected is based on the criteria in the payload in API request. It works well so far. There are new use cases that...
We all know that in a layered backend architecture we have the Controller (or view) > Service > Repository (or Manager) The Repository part is the part that retrieves and updates the DB. But now that we have ORMs that are fairly advanced, does the manager/repository part still relevant ? I know everywhere that it's the...
As far as I understand, there is no certain boundaries for the RESTness of an API. However, I would like your help to understand how large and long (in terms of running time) a caching or state mechanism would be fine to use with a REST API goal in mind. I read about stateless being no short lived state. The database p...
Apologies if this is answered elsewhere here but this specific question is somewhat hard to search for as you might see. I'm writing a script currently that essentially has a simple if-then within a for-loop like so: for(i = 0; i < length; i++) { if (a < b) { ... } } However I want to re...
RefactoringGuru's example Singleton in Python has an _instances dictionary field class Singleton(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls._instances: cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) return cls._instances[cls] ...
I welcome everyone. I'm trying to understand microservice architecture. The task such: is 2 services. The first - for example, books rooms in a hotel. The second is something like a console interface that sends a booking task to the first and waits for a response from him, saying that the room is booked or not. For thi...
At work, we're using Scrum with Azure DevOps (specifically using the Scrum process to manage our items) to run our sprints. My question is, does the Scrum process within Azure Boards or Scrum in general prescribe product backlog item (PBI) statuses. Specifically that they must be marked as Committed when brought into a...
I'm not conversant with this topic, and therefore I watched a tutorial about a one-page dynamic PHP website (quite educational in my opinion) in which the creator designed the following pages. For each and every ADD, DELETE and EDIT page, there are two additional files to create, making two per page. In other words, (...
In university, we were introduced to the two terms "verification" and "validation". The definitions can be summarized as follows: Validation checks that the specifications and requirements that were defined fulfill the customer's actual needs. (Do we build the right product?) Verification checks that the software that...
I am working on a project to stand up a central database to replace a current massive file-sharing/syncing system of physical log files and text configurations for the primary application I work on. The app I help develop runs on around 40 computers, each of which can generate hundreds of records per minute while activ...
My team and I publish a client app as part of our solution. It includes a CLI but there are other components as well. Currently most of us develop locally on MacOS, and as part of our CI/CD we have a suite of system tests that run end-to-end workloads, including the client application and our cloud service. Until now w...
At an architectural section of an interview I was asked to produce hardware requirements for a certain system I designed. It was a microservice-based system which runs in Kubernetes, Openshift or any other virtual env. Basically the question can be rephrased as: how much CPU, RAM and storage will every instance of micr...
We've been utilizing pair programming (or something like it) for a few years. As a senior engineer on the team - I find that pairing actually negatively impacts the team's throughput. The common pattern is that more senior devs generally end up handholding more junior devs throughout the whole process - basically codi...
To better context see Rich Authorization Requests for OAuth2 As u can read here there are some common data field types like actions, locations etc. So I have created C# entity for EF as below: public class AuthorizationDetails { public int Id { get; set; } public string Type { get; set; } public bool Always...
I have one bounded conext, offers, that has Offers as root aggregate and Items as child entity. I have another bounded context, products, which has Products as root aggregate, Providers as another root entity... but for the example Products is the entity that I need. Product has a price property, that is the reference ...
Let's consider the following test. [Fact] public void MyTest() { // Arrange Code var sut = new SystemWeTest(); // Act Code var response = sut.Request(); // Assert response.Should().NotBeNull(); response.ResponseCode.Should().Be("1"); response.Errors.Should().BeEmpty(); } I hav...
Background: At work I was tasked with developing a new demo web client to replace our Windows Form application in the future. Our back-end is developed in Java and works stateless as REST services. The demo client should be based on Angular as we want to try out some things first. Both I and other developers already ha...
In a distributred system that uses parallel processing to complete tasks and I want to determine when all sub tasks have been completed, what design method or principals can i apply ? I am using RabbitMQ to consume messages that are generated from a single process, each consumer can generate multiple messages to other ...
I have a set of complex data, which I use on various subdomains of my project. Data are static most of the time, it changes few times per year. Currently, it's hardcoded in every project which needs it, but I am looking for a way how to make one "source of truth". Of course, I can build another api.example.com service ...
An issue I find myself having with code layout in my React components is that I end up having to define too many handlers. I generally write only functional components with hooks, but within the body of the component function I find myself having to define a bunch of child functions, e.g. for a SignInDialog~ const onSi...
We are storing our configuration files in S3. Each file is a JSON file. When config changes, the old file is backed up and a new file replaces it. These happen behind a service, where it also maintains optimistic locks to deal with concurrent writes. We store changes as audit logs, along with the author and timestamp. ...
I'm trying to break down my dockerized monolith into a few services that can be deployed independently. Right now, I have a development environment, a staging environment and a production environment. I'm not sure how it's supposed to work for microservices, especially for the staging environment. Is every service supp...
Some decades ago working with IRC, I remember a paragraph of some RFC and now I'm looking for it. I don't remember it by memory, only a concept: When it comes to communication between two services, the server issuing the information must be gentle upon receiving the request, so that it can accept the sender's query wi...
Currently I want to create a SQL database effectively and "logically". Lately I read a lot about the issues that it is (mostly) not a good idea to define primary keys that can be seen from "outside" as autoincrement. And for my applications it would be a problem too/risk. As a solution I used UUIDs for this. However, I...
Is there a term that describes the property of being synchronous vs asynchronous? The term that most naturally comes to mind is "synchronicity", however I only see this term being use in psychology. I would like to use this term as a property label on APIs that I am documenting, however I want to see if there is alread...
Does it violating any conventions? Is it acceptable by MVVM? I have to separate the local data repository and online repository, but for login I have to use multiple repositories for getting response from API and saving credentials if they are correct I have implemented it just by editing the ViewModelFactory as follow...
I am building a .Net Core Blazor Server application. The application creates records of a Project class which move through a workflow with various phases of review and acceptance/rejection before completion. I am trying to determine the best place to incorporate various business rules around who can modify the Project'...
Whenever possible I have been requiring an understanding of the requirements and architecture for the next scope of work before starting to code. Sometimes due to schedule pressure on larger projects I have to start coding before I know everything I need to know for that scope of work, but in that case I make it a prio...
Let's suppose I want to follow TDD (Test driven development) and I want to implement a class that is supposed to return a considerable object. It starts to get really complex in my opinion and doesn't seem like a great design. Let me give a concrete example I'm working on, a class that contains some methods, and one of...
I was wondering if I have a microservice called, for example, Weather, and only certain people can update certain properties around the weather such as Temperature, Precipitation, and Wind. These certain users are mapped to the weather event, e.g.: User1 => Temperature User2 => Wind User3 => Temperature User3 => Precip...
I am facing this problem and would like to review my approach to it here. A Client sends an HTTP request to Service A and is expecting an answer. Service A is connected to DB A. When it receives a request from Client, it should save it in DB A and forward it to Service B. If it already exists, it should return a fail...
currently I am working on a kind of "Chat" Application. The app consists of "threads". Each of this threads consist of "subthreads" in wich a user can send a message (like a group). But there also should be an option to send private messages. Firstly I have to say that I have basically no knowlege about NoSQL-Databases...
My employer has a significant number of company-internal strings which require format validation. For instance, order number AAA-BBB-CCC, stock number AB-123456 or factory ABC1 - Regex with extras (think checksum, number range). Having re-implemented functions for every project I have been on, I wanted to publish a rob...
I am developing an API backend in NestJS, now for some specific routes (or controllers) I am loading in a configuration from the database to handle an incoming request. This fetching of the configuration is done inside my service (business logic), but I was wondering that perhaps this can be separated using middleware....
I am working on making changes to an existing Web API that exposes information about orders for specific customers. As a developer, I am used to seeing "more or less" RESTful APIs, and I would expect the URL for getting customer's orders to look like this: https://domain/orders-service/orders?customerId=<ID> However, ...
The main application loads plugins, list them and when user selects one it is initialized and displayed. Each plugin is a complex class library which contains several views/viewmodels/repositories/etc.. Is it a good idea in such a case to have in each plugin some kind of a bootstrapper and use dependency injection dire...
I'm creating a multiplayer game and have been having some trouble creating a good architecture for the server side. So far on the server we store a list of player which are the actively connected players, the main way they interact with each other is by shooting each other with guns. To facilitate this I decided that a...
Let's say I've a sendMessage endpoint. This endpoint looks at configured message destinations and then puts 1..N messages into a queue (e.g. {userId: 3, type: SMS, trackingID: X} and {userId: 3, type: EMAIL, trackingID: X}) and returns the trackingId. Now I want to expose /status/x, which will display an overall status...
I am looking at the List<T>.AsReadOnly() method. Since List<T> itself is a IReadOnlyCollection<T>. (It implements IReadOnlyList<T> and IReadOnlyList<T> implements IReadOnlyCollection<T>) the implementation of AsReadOnly() could technically be return this; which has no allocations. Instead this does return new ReadOnlyC...
Suppose there is a third-party application which offers GRPC services with authentication. You want to use these services in your web application. So you will basically use that service behind the curtains with just a few simple conversions (e.g. time is denoted in seconds in third-party, but you want hours on your sid...
I was going through an old, largely untouched part in my company’s codebase and found one API. It does the following things. A POST API with path host/entities/trigger which fetches a list of entity IDs from the database. For each of these entity IDs, it’s making another POST call to the below API in the same service (...
Over the years I've many times seen folks enumerate error codes for exceptions in Java. I generally have felt this leads to more tedious code and does not provide value. For example, there will be an enum like this ErrorType, often times with a numeric errorCode, which I find additionally egregious. package so.example;...
Our team is working on software that does a lot of calculations, inputs are quite immense structures and outputs are calculated data for the GUI (around 10 tables, warnings, and other messages produced deep in the code). I think neither the input data structures can be smaller, nor the outputs. The generated output to ...
I have these lines in multiple test methods. Now, trying to create a private method to clean up but not sure how to do it. Any suggestion or pointer would be really helpful. Thanks. var actualValiationString = string.Empty; void messageBuilder(string validationString) => actualValiationString = validati...
I am trying to build ERP application using React frontend and I have not found decisive answer whether to use object graphs in React state? E.g. I would like to build Invoice view and I have the following domain model (provided here partially): Invoice Person DeliveryAdsressArray DeliveryAddress Wa...
I have the following pattern repeating itself in multiple places: abstract class Database { void connect() { this.setStatus( CONNECTING ) try { await this.realConnect() } catch (error) { this.setStatus( ERROR ) throw error } this.setStatus( CONNECTED ) } abstract void re...
I'm adventuring myself in the world of ES and CQRS and I've been reading a lot about it. Unfortunately, most materials don't go beyond the basics and when you start trying to apply it to real-world examples you start stumbling into stuff not covered in the examples. My question is regarding related entities. Imagine we...
I am creating a distributed chat system with a microservice architecture where a user can log in and chat with another user. The services that I identified is a conversation service that handles chat-related logic. Message service which handles and saves the messages and a user service that just has a simple authentica...
I'm just starting to build a web app using React.js, Next.js, Prisma, & PostgreSQL. In this web app, users can create "projects", which are represented by 10-15 rows in the database. When users make changes to the project on the client-side, what is the best method to synchronize the database? Here's what I've consider...
I am new to microservice. While learning about them, I was wondering what is the basic rules (the minimum) that make a microservice a microservice. I have found some rules/characteristics along the way: Required: Loose-coupling, independent and scalable web services. Doesn't have to be the same technologies, but must ...
I have read this example:https://auth0.com/blog/securing-grpc-microservices-dotnet-core/ In this example it explains how to implement authorization in a gRPC service. It says that the client request a token that let the client call the service. For that, it is needed to include in the json file the public and private d...
I have an algorithm that runs a search through every combination of a 5x5 grid where each cell can have 3 values, looking to see which combinations meet certain conditions. This gives 3^25 naive combinations. However, rotating the grid 90 degrees doesn't change whether or not it satisfies the search conditions, nor doe...
Backend: Django / Django Rest Framework, would be hosted at GCP k8s Frontend: Angular, would be hosted at some CDN e.g Vercel Authentication: JWT (https://github.com/jazzband/djangorestframework-simplejwt) The frontend and backend would have different domains. (could be on same domain but different sub-domains) My fl...