instruction
stringlengths
34
36.1k
When I'm sending a request, the raw log looks something like this: GET / HTTP/1.1 User-Agent: PostmanRuntime/7.36.3 Accept: */* Cache-Control: no-cache Postman-Token: 3d4eba45-388c-462c-a174-e003d2a36456 Host: google.com Accept-Encoding: gzip, deflate, br Connection: keep-alive ----------------------------postman Con...
We are currently developing a product in the AWS environment that requires instantaneous data consistency for DB transactions that span multiple schemas in a Aurora postgres instance. Each schema will be updated by a service/micro-service/lambda orchestrated through step function workflow. The only solution we came up ...
Windows: Uses CR (\r) in combination with LF (\n) for line endings, facilitating compatibility with legacy systems. Unix-like systems (including Linux and macOS): Employs LF (\n) for line endings, offering simplicity and compatibility with text processing utilities. Older Macintosh systems: Uses CR (\r) for line ending...
I got a fundamental question about the $this keyword in PHP and how it is defined. Pracitcally, I know what it is and what it does. But I am interested in how it is provided / implemented? For example, in C++ or Java, it is passed as a hidden parameter when calling non static member functions / methods. So from the com...
Generally speaking, the basic flow is: http triggered service method puts request on service bus service bus triggered method executes request and in this specific scenario: method from 2) sends request to external service with callback url external service sends confirmation to callback url Full disclosure: anothe...
In the book- The Art of Unit Testing, I have read that the changes to the code base should not change the unit tests. But I have a hard time figuring out what should not be changed in the unit tests. Is it the behavior being tested or the code in the unit test? For me, changes to the test project code seems inevitable....
I'm developing a trading platform using Django, where users can publish trading signals with specific stop losses. I'm facing a challenge in implementing a real-time feature to automatically mark signals as 'failed' when the cryptocurrency price hits the designated stop losses. Here's the specific scenario: Assume I ha...
I'm thinking about implementing garbage collection efficiently by protecting the structure that tracks allocations using reader-writer lock. However, I'm worried memory semantic may invalidate the idea. In essence: whenever a thread operates on some objects created using my GC library, they acquire the "reader lock" a...
Our team assigns time estimates to tasks (not stories) in a group setting, so one of us will give an estimate that then anyone who picks up the stories has to meet or else gets questioned about it. Everyone has different levels of experience with the code so the estimate from one person might be way lower than it would...
I use CQRS for most of my applications. My request objects contain the data needed by the Handler to perform the Request. However, I've started to realize that some data points we have are required on every single request and are more contextual to the request. For example, the ID of the specific Division the request i...
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type as possible. However, I found that a situation that declare the exact type instead of the most abstract type may help me to write more maintainable code, for example, I'm...
I am taking a networking course, and am trying to understand protocols such as tcp/ip, DHCP etc. I did a google search for the source-code for TCP/IP protocol, and learnt that it resides in the kernel of the Operating System; Basically, TCP/IP implementation is the responsibility of the kernel of the OS. I am trying to...
In a legacy project's service layer, there are tens of service classes and among them there is one service, UtilityService using 2 other services: class UtilityService{ private UserService userService; private ContactService contactService; //some methods using userService and contactService } This Utility...
I thought this might be a thing to happen regularly, but I might be wrong. I have a process that is quite clear in its structure. But: We are in a multi-provider environment and at the very beginning of the process, the actor himself does not know what meta-role he is in. I am not talking about the roles within the poo...
I was currently developing a PoC of a "core banking system" in my current company, a pawn shop that generally offers lending services to retail customer and deposit services. We've built a legacy system since 1998 using FoxPro DOS and this year we have successfully rewritten our platform using Java Spring Boot. As time...
In C#, strings can be used like objects with methods, properties, and other features of objects. At the same time, strings are treated the same as primitive data types like int or float in numerous ways as well (lowercase name, behaves like a keyword, etc.). In Java, strings are just objects (String), and it is very cl...
Does discussing the behavior of static classes make sense for IOC? It seems that in the case of a life cycle transient such a description is misleading and untrue: However, it is guaranteed to be loaded and to have its fields initialized and its static constructor called before the class is referenced for the first ti...
I am trying to use CQRS in my project and I was thinking how the GUI gets notified about failures in the GUI, when commands are fire and forget. My commandhandlers are not returning anything, but emitting domain events, that capture the result of the command. Lets say in the classical example of an ecommerce app. If I ...
I'm designing a web application and using Microsoft's out of the box Identity and its default Two-Factor Authentication (with Asp.net core MVC and .NET 8). While setting up and testing the 2FA functionality, I noticed the Authenticator phone app only allows the use of one Authenticator account to one 2FA setup. Here is...
I am trying to understand the difference between bare-metal servers and cloud servers. I am referring to the following document,blog. I understand that Amazon EC2(which is all the rage) is an example of cloud servers, is there any benefit of bare-metal servers over cloud servers like Amazon EC2? In what scenario will w...
I am trying to understand the concept of storage virtualization. Based on what I have read, storage virtualization appears to be synonymous with cloud storage. Based on my understanding, Amazon S3 is an example of cloud storage. It is a technology where data is stored on remote cloud servers via API. How does virtualiz...
I have in project linq repository unit tests. [Fact] public async Task Get_FromTreeEntitiesUnsorted_RetunsOrderByDescending() { //Arrange _contextReadonly.Entity.Add(new Entity { Id = 1, Source = "1", Date = DateTime.Now.AddDays(1) }); _contextReadonly.Entity.Add(new Entity { Id = 2,...
I'm writing a pretty common Symfony web application, in which HTML is server side rendered (it's not an SPA application). To illustrate my question, let's take a pretty common fictional eshop application which has these bounded contexts: Order Product ShoppingCart Let's imagine that on the same web page must appear t...
Having fewer lines of code per feature is typically better as it increases the developer productivity. Did anyone ever measure the number of code lines executions per line of code across multiple programming languages? I.e. each line of code is annotated with the number of executions of this line? Are there any statist...
I am trying to understand various types of virtualization techniques. The concept of Hardware virtualization/Virtual machine was simple enough. However, I am struggling to understand the concept of storage virtualization. One definition I have found grouping the physical storage from multiple network storage devices s...
Problem: There are proprietary algorithms that developers who are actively working on a project will need to call but they should not see the underlying logic. They need to be stored in an area of Source Control that a limited number of developers have access to. The base application will handle user input, data acce...
A wrapper is often explained as modification of an interface to another function with very little added functionality, if any. I've seen scarce reference to a "thick wrapper" that does add nontrivial functionality. Is there a broadly recognized term for a thick wrapper?
Some context here: I am developing a comparison tool that coalesces, formats and concatenates all column values for the individual rows in a table. This single string is further reduced in size by converting it into an md5 hash. In addition to reducing the entire row's contents to an md5 hash, I will do the same with t...
I have an api which returns records given some constraint. Let's say 50000 records meet the constraint. Because we can not return all the records at once, so I have to implement pagination. I am also showing that there are more pages of records. To solve this i am Counting the total number of record that match the con...
As far as I know, coupling is about counting number of other classes in a class, so for the following program that emulates a UI program that shows "WelcomePage" at start and also pops a AboutDialog that requires token to fetch information to show, lets count the number of "other classes": Global state version: public ...
I am trying to understand various virtualization techniques, and I am struggling to wrap my head around the concept of Network Virtualization. In case of the server virtualization, the objective is the most efficient use of hardware(using hypervisor), and the alternative is the under utilization of resources. Does that...
I have a Python FastAPI server application which naturally guides you towards the asynchronous paradigm. For legacy reasons, I have to support two backends, one which is purely synchronous and one which is asynchronous. These backends roughly have the same functionality. Are there any best-practices on how you could bu...
I recently discovered the KISS and YAGNI principles which made me question my usage with classes because I use them constantly without really thinking about it and I realized my code could be much simpler without them, but at the same time there doesn't seem to be a reason not to use classes like even if you don't util...
I wanna be sure if objects "contain" methods just as they contain their fields. Also, when you use the term "object", are you talking specifically about its fields?
I am currently learning about BDD (Cucumber/Gherkin) in test automation. I am wondering about reusing simpler test scenarios or step definitions for more complex scenarios. Specifically, I am working on network testing. For example, say I have the following (generic) test scenario: Given a switch with ports {port1}, {p...
TLDR: I'm looking for advice on the most straightforward method to set up an SMS system using my own SIM card, without relying on SMS service providers like Twilio or MessageBird. Currently, I am developing a custom appointment system for a doctor, using NEXT.JS and SUPABASE. The good doctor wants to send an SMS to his...
According to Explanation on how "Tell, Don't Ask" is considered good OO, I know the following is bad: if(a.isX){ a.doY(); } public class A{ public boolean isX; public void doY(){ } } which I should modify it to a.doYWhenX(); public class A{ private boolean isX; public void doYWhenX(){ ...
One post can have many comments. How can I design REST API urls for HTTP POST and HTTP PATCH for comments. My idea is to have the following endpoints: HTTP GET: /posts/{postId}/comments HTTP GET (all comments): /comments HTTP POST: /posts/{postId}/comments HTTP PATCH: /comments/{commentId} Are these urls correct? Beca...
We have a .net core app with the following folder / onion structure: WidgetApp -> Core -> Application -> JobAutoStarter -> JobAutoStarter.cs WidgetApp -> Core -> Domain -> Entities WidgetApp -> Infrastructure -> Hangfire -> WidgetJobs -> Job1 (hangfire job logic) WidgetApp -> Infrastructure -> Hangfire -> WidgetJobs ...
I'm creating a web application with Asp.Net Core MVC, and I've replaced Entity Framework with a custom data store. I've decided to use Dapper, but have never used it prior to this project. So I'm learning what I need to as I go. One of the examples I referenced to help replace EF with my own custom storage provider use...
Context: I have an API (using DDD) with an entity lets call it "Content" that only can be update by certain users. For example Content with Id = 1, can only be modified by User Id = 1, Content with Id = 2, can only be modified by User Id = 2, etc... I'm using an external Identity provider (Auth0) and of course I'm usin...
I have a scheduling system that is horizontally scaled, and stores shared state in a redis key. The purpose of the system is to implement something similar to classic rate limiting, but a bit different in that I want to track the amount of currently active requests, and the sum of the "weights" of each request (as some...
We are implementing an application by trying to follow the Clean Architecture template for C#. Our application is an ASP.NET core web api and we want to implement the observability for that application by using Application Insights. In both the UI layer (which is actually the web layer where the HTTP endpoints are defi...
In all programming languages, every command is sorted as command-arguments. For instance, in pygame, the command to draw a rectangle to the screen is: pygame.draw.rect(surface,color,rect) This seems rather odd to me thinking about it. Wouldn't a verb-final (or command-final if you prefer) order make more sense? For ins...
please note that while I refer to a specific web application framework in the following, the problem also arises with most other web application frameworks I know so please don't be afraid to reply even if you don't have experience with NestJS. I have a web application with NestJS that runs on Azure Appservices (or AWS...
Scenario: We have a application (web based), in a small part of this application a users is able to create a small python script to mutate (in memory) data. Currently all of these scripts (if it is directly run from the frontend) are run on the same docker instance. We want to separate this so there is 0 chance of diff...
We are trying to rewrite a session management system as our legacy system can't scale up anymore and is quite buggy. I'll briefly explain our system, we have huge number of machines on which end users create a session and our system is supposed to track what happens during a session. Any activity that an user does on t...
As far as I understand (not much), the archival .a file is just, roughly speaking, the collection/batch of object .o files. It's like a library of compiled code that can be cached and which can be used later by the linker when creating the exe file. So my question is there any logic for the .a file to consist of only o...
Is it possible to have an association without explicitly indicating the reference attributes in the participating classes in the UML class diagram? For example, consider this example : We can see there is an association between the customer and order classes, however, from the attributes compartment of both classes, I...
We have a REST api endpoints that return collections of objects where users could perform different types of actions on those objects. We need it to turn on/off different UI options based on that access info. We are thinking about packing them as metadata into each response object but I can see that become inefficient ...
I have an endpoint similar to GET ../produtcs/123 where 123 stands for an ID. The REST service response with either status 200 and a json object A {"deliveryData": {"status": 200, ...}} or with status 401 and a json object B {"error": "foo", "status": 401, ...} There are similar question (1, 2, 3, 4) but in my case i...
Background: I work on a small group (5-10) of lightly used .Net web applications. The applications typically have dedicated databases, but there are instances of an application accessing another application's database directly. There is also a common database that most of the applications use a source of truth for som...
My question relates to this topic here: Are classes with only a single (public) method a problem? There I read in the comments often something like that: It is no longer object oriented. Because those classes don't represent anything, they are just vessels for the functions. So my question is, how to write that the o...
I plan to build a website where landlords can manage their properties. The website will collect data about each property and then do useful things with that data -- produce reports, email alerts etc. Most of the website is just going to be collecting data and then a small part will be querying that data. So I want to u...
Imagin I have two microservices that need to send email to a customer about some important account realted things that happened. For example, Billing service would like to send an email when a card has expired and Users service when a password was reset. These two services use the help of another service, let's call it...
So we have a cluster with namespaces representing different domains. Services in one namespace cannot directly talk to services in another namespaces unless routed through a load balancer. ( goes outside cluster and comes back) We are designing service mesh for the cluster and a api gateway both of which will be in the...
I am writing a compiler in C++ 20. I am looking for ways to improve heap memory performance. For example, I can compile a 36.8 MB source file that is just many repeating lines of: let x0: string = "hello world"; let x1: string = "hello world"; let x2: string = "hello world"; let x3: string = "hello world"; ... let xn:...
We have a piece of code that decorates an interface to transparently add retry logic. Inversion of Control configuration service.AddOurRestApiClient() .AddResilienceHandler("Retry", builder => // decorate our REST API client with retry handler { // Add retry policy so request is retried when a // tran...
In Javascript, the iteration order of an Object is enforced since ES2020 (or before, depending...). However, is it a good idea (i.e. best practice) to depend on this? I'm currently working on a website where the backend (NodeJS) needs to send a map of data to the front...but the keys need to follow a certain order (def...
I have a git repo with nested submodule dependencies (see picture as an example). There are duplications because each repo needs to be compiled standalone in a pipeline so that the corresponding test executable can be run. Currently, this is solved with submodules. If E gets a new commit, I need to update submodule po...
In java we generally do it the java-docs way and in js the popular method these days is vscode documentation using @param, @returns, @example etc but I would prefer if there were some language agnostic and IDE agnostic way to do so; probably, backed by some RFC; anyways, the most I can come up with is using markdown wh...
I would like to be able to build up a log of user activities, capturing data such as who they were, where they logged in from, what activity did they take, and what data did they change (both before and after). Most of the user-related data can easily be picked up by middleware running on my web server, that can hook i...
Loose coupling promotes testability because it allows components to be tested in isolation without having to test the entire system. This can help to reduce the risk of introducing new bugs by making it easier to identify and fix bugs before they are integrated into the system. How can testability help in identifying a...
I have been doing a lot of thinking lately about the implications of event-based/responsive programming and UML statecharts. I believe my thinking up to this point has been flawed. Take, for example, a toggle button/switch. It has an internal state: pressed or released. It also generates events: press and release. T...
We have 3 subscriptions in our Azure management group: DEV, TEST & PROD We use Azure Maps to get weather insights data via some Databricks jobs In order to roll things off quickly, we replicated the setup in all three environments and all is working well Now as a part of efficiency and cost optimisation, we want to reu...
I'm trying to better understand cohesion and coupling. More specifically, I'm trying to use examples to better cement the concepts and one of the most common examples I see goes something like this. For this "bad" code public void Process() { string connectionString = getConnectionString(); SqlConnection connection...
I have a time-series database where I put all my data in it in timely-ordered fashion. Unfortunately, the database doesn't have any realtime listener capability built into it, and I need to make an app that responds to any changes happened to my dataset. Using that as the context, I came up with idea to regularly query...
For learning purposes and fun, I created an Expo Go app with react-native for recipes. It has a firebase database and uses redux to manage state locally on each device. So far so good. A couple of friends are actually using the app encouraging me to improve it even further. To get started, I decided to load all data on...
I work with a integration project based on Publisher/Subscriber pattern whose subscriber end feeds a staging database which stores data to be pushed to another application. The staging database has some views which are responsible for providing data the the final application We use DataDog for observability, but since ...
According to What is a "side effect?", I know the side effect means changing outside world. But what if a function that changes the outside state during execution, but reverts the state to original state after execution? For example, originally I have a function about physics simulation that doesn't modify the outer va...
In the Collaboration diagram, we represent a message with a solid-headed line : Moreover, in a sequence diagram, we can show a synchronous message with a solid-headed line and an asynchronous message with an open arrowhead: Is there a way to indicate a synchronous and asynchronous message in the collaboration diagram...
When creating a distributed web application, cache invalidation can be a big deal. However, our web application doesn't need distributed load, as we don't expect to serve more than 1k users at a time. For now, we've had a multithreaded asynchronous web application written in Rust. The web application is run on only one...
In UML we have two special messages, create and destroy. These two messages describe the creation and the destruction of objects, respectively. We must use the stereotypes << create >> and << destroy >> for them. In the UML sequence diagram, I see that sometimes we create a message using a closed solid arrowhead and s...
I need to process status changes related to an entity in a sequential order. Not in parallel. Will an SQS FIFO Group with MessageGroupId = UserId be enough? Let's say I have the folowing messages: MessageGroupId = 1, status: :pending MessageGroupId = 2, status: :pending MessageGroupId = 1, status: :approved And I hav...
Should one enforce reasonable values when modeling one's domain? Here's an example: Assume that we have a scheduling application that schedules visits for people who require assistance and normally one would not schedule a visit more than a maximum of a year in advance. Should I then enforce that by saying that a visit...
I'm currently writing an MVC application and I need a class that can: A: get, add and remove data(specifically a TreeSet of sorted strings that I want stored in memory, but I doubt the data itself is relevant.) B: The data must be accessible to multiple controllers. C: There can "presumably" only be one instance of thi...
I work within a poly-repo that is worked on by multiple other teams, each in our own separate sections of this main repo. I am coming to make my first push to production and I am unsure about strategies for doing so. A traditional code-freeze on the Master branch isn't feasible due to the amount of teams and the freque...
I am storing a large (~1M per year for ~30 years) amount of text files in file-based storage. Each file is named FFFFFFFFFF-YY-SSSSSS.txt where FFFFFFFFFF is a 10-digit filer key, YY is a 2-digit year, and SSSSSS is a 6-digit incrementing sequence for each filer in each year (so it starts at 000001, etc.) I wanted a s...
I have been asked to give a 45 minute talk on my team's system architecture to an incoming product manager (PM). Well, this PM's "mentor" highly recommended asking for one. I'm comfortable giving this talk to a room of engineers—we use gRPC, microservices, GCP—we own some of the source of truth in a Postgres database, ...
I'm trying to experiment with SOLID in order to get a better grasp of its' concepts. With that in mind, I'm making a card game project. There's a GameUtils project that contains the following classes: IPlayer, ICard, and IDeck. Then there are projects for each game, such as Hearts, GoFish, and War. Inside those proje...
When talking about integration level of automated tests, I suppose that end-to-end tests lie at the first extreme: they know absolutely nothing about the internals of the app they test, they just run the app and see if it behaves as expected. On the other extreme, unit tests in the classical sense lie: they test only a...
The second and last question in my current series of questions about TDD and unit tests... For the purpose of this question, a 'unit test' is defined as a test that focuses only on a particular method and that mocks all dependencies of the class of this method. (As opposed to any other sort of automatic test, such as a...
Lombok is used in the legacy project where I am currently working for since last year. The project is legacy with 10+ years, and POJO/JavaBeans, i.e. @Data annotated classes, have been widely used for probably 10+ years. However, since I have been using Lombok for many years in other companies, I just prefer to using t...
We all know the standard TDD cycle: I first write a unit test, the smallest unit test that fails; then I write some production code, again the smallest amount of production code that is sufficient to pass the test; finally I refactor. In this way, it is hoped, I will produce code that is 100% covered by unit tests. Not...
I have the following operations: User submits event We store event in a queue Wait for events and store them in db for redundancy Wait for events and process them Remove events from queue and db For performance reasons, op 3 runs on a different thread. The queue is always accessed under a lock, since events are submi...
When you look at products like the Razor view engine, there's a clear reason why Microsoft decided to subset another existing standard (HTML) with their own special sauce thrown in. But I cannot find any concrete examples why Microsoft decided to subset XML and go with a completely identical standard: XAML. It seems li...
I am working on building a workflow orchestrator (like Camunda). It has nodes of type event. This represents a message has been received in the kafka topic which the orchestrator is listening to. The workflow orchestrator now gets the related workflow instance, mark current node as completed and runs the next node in t...
Consider the following level - 0 dataflow diagram for a patient management system : Consider the doctor entity, the system provides an appointment report to the doctor. If the system only generates the report upon a request from the doctor, do I must include an outgoing ( from the doctor entity ) dataflow labeled as f...
I have a singleton that needs to be initialized at the start of the program and it will live on until the end of the program. As is usual in this pattern, a function initializing the singleton creates a static pointer member to itself that is returned from the get() method. My usual C++ instinct tells me that if someth...
I'm designing an Azure Service Bus topology with multiple topics. Each topic is associated with a single message type: this is possible since we have a limited number of message types, each one with a well defined semantic meaning in the business domain. Each one of this messages has the meaning of an event inside the ...
From the book Essentials of Systems Analysis and Design by Joseph S. Valacich, Joey F. George, Jeffrey A. Hoffer, we have a study case, with the following 0 DFD : This diagram raises the following question: Why do we have the data flow Product Item: Does this flow mean the system is adding a new item to the inventory...
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know "init()" method is a code smell, and "physically make them two separate classes" is a way to refactor the "init()". However, I don't understand what is the meaning of "physically make them two separate classes". Is it mean move the init ...
For example: After I've learned about SQL injections I realized that in past projects I didn't check user inputs for SQL injections. After I've learned about PKCE I realized that in past projects I didn't use PKCE in OAuth 2.0. Each time I have these enlightenments, I feel bad about my past projects. My inner voice s...
I use code like this and it seems to work fine: void addActions(const vector<zero_arity_function>& _actions) { actionsMutex.lock(); for (auto entry : _actions) { actionsToRun.push_back(entry); } actionsMutex.unlock(); } And the corresponding code that the other threads runs: void runActions()...
We have some domain primitives for representing an Account an Amount with Currency etc. These are in a shared library, so all our microservices can use them. And then we started adding some convenience methods like Amount.of(String currency, BigDecimal value) and Account.fromIdentifier(String) etc. These are really con...
In my current workplace, I act as lead developer and architect in a team of software developers. The general policy for merge/pull requests is that 1 person has to review and approve the request. This person must not be the author. Sometimes code is merged which I personally would not have approved for one ore multiple...
I want to model a system where someone is creating Quiz and he can choose who should do the quiz. When submitted the invited people have a deadline to solve the quiz and the creator and maybe some other guys have the authority to see the status of each Invitee, whether they finished it or not. (Basically it is kind of ...
Given the two models company and person I'm noticing duplicate fields i.e. zipcode, emailaddress for each. Yet, a short research reveals a reasonable popularity for separating those two entities into two tables (in terms of customer relation management databases [crm]). Would one contact table with appropriate fields o...
It's been a long time that I had an idea of a semantic constraint as compiler optimizations which allows for sophisticated high level optimization allowing you to transform the AST/CFG based on a SFG (semantic flow graph). To give you a simple example I'll simplify the code of a reddit question which asked about two ve...
I have to update app code running in a container on AKS to use a WorkloadIdentityCredential. I have to test code that I update in order to pass CI quality gates. The code uses a public final class, com.azure.resourcemanager.AzureResourceManager, whose constructors are private. The only way to get a new instance of this...