instruction
stringlengths
34
36.1k
I am currently writing a PHP / JavaScript application library, which I intend to use in the future for several other applications. The library includes functionality for handling a database, creating users / hashing and checking passwords, etc. I am wondering whether there are any accepted best practices on how to orga...
I need to decide about my database architecture. The app provides files for download. I can add a counter to every file and track total events. But the client may want some analysis and ask for the most popular content over the last 30 days. In this case, the download counter would not work anymore. Alternatively, I ca...
Conditions: stable legacy prod system no Software Devs of the system are available anymore app is maintained by Engineers, who do not have the same software dev experience like the original Devs and almost none for that specific system there are issues requiring debugging of the code, and the remaining Engineers have ...
According to Why is Global State so Evil?, I know I should not allow the existence of global state, one of the reasons is so called "it makes program state unpredictable". However, I'm not trying to oppose "not using global state", what I don't understand is, why do we say "global state" makes program state unpredictab...
I am trying to understand when does it make sense to have independent layers versus merging layers together. For example, let's say there is a wallet service where you can keep money in separate buckets like food, household, electricity, travel. Money can be redeemed across multiple buckets as well, for example if suff...
I wanted to implement login system using flask framework. I managed to do this using sessions and set them to expire after 31 days and it works (sessions are created using server secret key, timestamp and cryptography by flask). But there is one thing that is concerning me and that is session id that was created before...
I am part of a project that develops a software with quite a clearly defined in- and output. But the path (a chain of intermediate steps and artefacts) is not yet clear. We start with a toy-ish approach to get a very minimum MVP and want to refine then to finally get going. Being agile I get that you add features itera...
My current situation: I would like to apply this to a solution containing multiple projects (one executable and different libraries) in C#. Additionally, I have a project that packs the executable, libraries and the .NET (currently v6.0) framework into an MSI installation package, which name should contain the product ...
I'm working on a game from scratch in C++ which is based on an Entity Component System and I've ran into a bit of a problem with the way I've been designing my systems and components. I find myself making fairly big systems that handle all the behavior for an entity or in other words I have systems that operate on 1 en...
We have a frontend application in React and a backend application in .NET Core which were deployed in a single Kubernetes cluster of 3 pods (it can autoscale). Before the application, we have a load balancer and an API gateway. We have a page which lists the clinicians and, on clicking, a process runs to create the pay...
Using C#, I got a class called BaseConfigurations which handles CRUD operations. This class also contains a protected method which is used inside the CRUD handling methods: public class BaseConfigurations : ICRUDHandler { public virtual bool CreateSetting(string someData) { //some logic Protecte...
I'm struggling to understand pros and cons of the C++ and C approaches to console output. C++ uses the stream approach with concatenation of operator<<, while for "C approach" I mean a print function taking as arguments a string with placeholders and values to be substituted to placeholders. While I like the C++ approa...
I'm working on a project with the task of creating a route to checkout ticket purchases for events. In this scenario, I have a controller that receives the request with order data, client information, tickets, and payment details. Subsequently, I pass this request to my use cases to perform the tasks. However, I have a...
Hello I'm currently designing an GUI application who's main job is to update and display settings and some other data. For context, I'm using QT framework. I'm starting to refactor the settings because the list of settings has grown and now we're having an issue where there's inter-setting dependencies. For example, th...
We're working on a new project (backend, API), following the "clean code" and "clean architecture" principles (described in Robert Martin's books), dividing our application into presentation, domain, and data layers. The presentation layer handles routes and data formatting, while the domain layer contains the business...
I'm seeking clarification regarding the usage of timestamp without time zone in a database and its corresponding Java type, LocalDateTime. The current setup I'm working on involves servers and (PostgreSQL) databases running exclusively in UTC. I've encountered numerous recommendations suggesting the use of timestamp wi...
I have been programming in C#/.Net and other languages as a hobby for over 6 years, so I do not have adequate knowledge about application architecture, hence my request for advice. The current solution I'm working on already contains 5+ applications (ASP.NET, WPF, Conosole), and growing, plus service classes and other ...
how could we advise the web client about a non-recoverable exception thrown by the persistence adapter ? At first sight, I would define a domain exception to be thrown by the persistence adapter and use an exception handler, within the myproj.adapter.in.web package, to catch that exception an send an HTTP error code a...
I am building a library website (sort of) based on django but I'm getting lost in the security paradigm. The user can choose a book from the system library or upload their own books. The book is then added to their projects for them to embelish. The library is public but user uploaded content isn't. Right now, I create...
I wrote a relatively small user interface for Unity, whose job is to ease working with parts in a scene, i.e. show/hide/toggle objects to reduce clutter. Long story short, I refactored it to use their new UI API and also started using commands, this allowed me to halve the code. Although it's pretty easy to understand ...
We currently have a backend authentication mechanism in place that utilizes JWT tokens. Users sign in or sign up using email and password, and upon successful authentication, the backend issues JWT tokens which are stored in the frontend's local storage or cookies. These tokens are essential for user authentication thr...
Might be silly, but I'm looking for a way to programmatically enrich images of vehicles with some technical, length measurements. Images will always: have a white background have the same angle (side of vehicle shown) Vehicles will always: have the same wheels have the same color have different dimensions (longer/sh...
For a game I'm making I have two objects; Gun and ReloadSystem. At the moment, these two object reference each other. Gun tells ReloadSystem to perform a reload when the gun gets clicked, and ReloadSystem changes the ammunition and tells Gun when it can shoot again. My idea is that these objects are a composition where...
In my application I have requests and items, each of which are associated with property tuples (key value pairs, where keys can be repeated) stored in a Postgres database. The goal is to find a single matching item for each request, after which they are paired and removed from future searches (basically this a queuing ...
My friend and I are developing a screenshot tool for Linux where the screenshot can be saved into a clipboard by using an external tool like xclip or wl-clipboard. Since there are even more clipboard managers (as listed in the arch wiki for example) we'd like to add an entry in our config file so that the user can deci...
I recently started using Semantic Versioning. Due to conflicts with my previous versioning convention (which I created myself), I am very confused about versioning unit tests as part of the public API. As mentioned in the SemVer documentation: Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backward compat...
I am building a web application with the React + ASP.NET Core template. The application will have a form for uploading recipes, including an image. I am hosting the application as an Azure Web App (App Service). My question is: What is the best practice when it comes to storing the uploaded images? The first thing that...
Consider an application with a fixed amount of tasks computation per cycle (let's say 100ms) that's usually done with manual scheduling. With 100 sub-cycles of 1ms, knowing and cutting each calculation task into smaller chunks allowing that in sub-cycle n°43, task 102, 103 and 104 will be perform for example. The advan...
Cricket scoring is complex and I want to build an app in part to practice good design principles/patterns and develop a clean solution. A few high level classes I have in mind are: Match | Innings | Player | BallScore | TotalScore There are states, some noticeable are following: CurrentInnings CurrentBatter NonStriker...
AWS Amazon.S3.Model.PutObjectRequest is merely a 3rd-party AWS Data Transfer Object (DTO) / Plain Old C# Object (POCO) type that can be used to build a request that can be used to send requests to an S3 Bucket. (reference The keyContentDictionary Dictionary will contain: a key that will correspond to an s3 Bucket entr...
Scenario/Context There is an old monolithic desktop application (running locally) which uses ODBC to connect to SQL database (on premise). This desktop application should be replaced with a new web application (microservices in the public cloud). As the application offers a considerably large amount of functionality, t...
I have one object, its class inherits all property from GUI class, that takes and some values and one function during instantiation, that handles click and upon receiving the click it calls the function which it received during instantiation. Due to some reason, I need to convert this object to another type object, fo...
Firstly let me say I have never written a unit test in my life. I am trying to get the hang of PHPUnit, and so far it's working pretty well for me so far as "stateless" functions (that simply take in an input and return an output regardless of whatever else in the programme is going on, and create no side-effects) are ...
I'm trying to come up with a peace of code that would fetch centralised cache shared across multiple threads/app instances. Callers might come in swarms. The data is a large set, reads during reloading are not desirable as they would likely yield incorrect/incomplete data. Let's say about once a day (not much more freq...
Im am developing a logistics application and at the moment, I try to solve the following problem: In the system, there are multiple machines. Each machine has one or more skills. For example, machine 1 can have skill A and B and machine 2 can have skill B and C. Users can make reservations like: At some unknown time i...
I am having difficulties on understanding when I should be worried about TOCTOU vulnerabilities and how to avoid them because yes, we can use database transactions but there are different level of transactions and using the one which is the safest would slow down the code. For example let's suppose I need to check if a...
I think my team may be doing agile a bit wrong but I can't put my finger on exactly how. After a collaborative design of a feature that'll take a week or so to accomplish, we break into tasks which is standard. But we then bring each task to 100% compliance wrt things like test coverage and docs. Each task item isnt in...
there is an app with lets say, 75 years worth of development in it. The frontend is a bit a chaos, there is jquery, there is vuejs (vue 2 of course), there is a lot of server side rendering with over 1200 files. What process would you consider to moving it to something that does not feel messy and that allows easier gl...
TL;DR why do people pick YAML/JSON/ini/TOML/XML/plain text to configure applications/packages instead of having the configuration be defined in source files the application/package is written in? I mean, I can see some obvious reasons that pertain to particular cases: Your code is written in multiple languages and the...
I am very unfamiliar with the Mediator Pattern in practice, but it seems that the core is decoupling events from handlers ("Colleagues"). The benefit being "lose coupling" in the sense that you can change code in a "colleague" without breaking the caller and vice-versa. In that sense, this seems like what an in-memory ...
The Rust programming language offers a Arc atomic reference counting generic type for use in multi-threading environment, since Rc is optimized for performance in single-threaded applications, and lack multi-threading protection. However, imagine a case where a thread trys to acquire a resource that another thread is r...
TLDR: I have three subclasses, each inherits from the same parent class, each defines an identical method that does almost the same thing, except that each of these methods has a different return type. The return type does not affect the logic of the method in any way. To get rid of this repetition, I want to be able t...
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...