instruction
stringlengths
34
36.1k
When domain modelling, should a valid constraint - or "natural" constraint - be modelled, even if there are no current business processes which rely on the constraint being asserted. As an example: A model contains a class Person, with sub-types Adult and Child. Child has the attributes father and mother, which are bot...
Say I have the following stream: List<Other> list = Stream .of( new MyObject(), new MyObject() ) .map(this::mapToOther) .collect(toList()) ; So after this is executed, I will certainly get a list of Other in memory, but I wonder whether the source objects (i.e. MyObject) are still "ali...
According to one definition of "interface segregation principle" that states currently in Two contradicting definitions of Interface Segregation Principle – which one is correct?, a client should not depend on the methods that it doesn't call at all, for example: public interface IData{ public void create(String na...
When I search the internet people said there was a 'study' that says developers write 10 lines of code per day come. Other results claim the mythical man month says it. I searched a digital copy of the book and didn't find it. Is this quote made up and went viral? If it was real what year/system/language/hardware were ...
As new code is released to production, without enough direct access to production execution environments I rely only on user traffic for monitoring. However not all use cases get covered via user traffic. In such scenario what is the recommended approach to perform thorough full-fledged monitoring (including an automat...
I work for a standards organization that publishes an exchange standard using XSD files. These XSD files are being generated from a model with a tool, and now we want to change to a new tool. Because these XSD's are part of a published standard, we can't change them functionally. Every XML that is valid for the old XSD...
If I'm not mistaken, a major part of testing software is deploying and using it on your platform of choice. For critical system software such as UNIX utils, package managers, desktop environments/window managers, kernel modules, etc., how would a developer reliably test the software without bricking their development e...
In Scrum we do a 2 week sprint and ship the features after the sprint. I have heard a lot of good things about TBD, but does it conflict with Scrum? Can anyone share your workflow if it is possible for me to switch from feature branch development workflow to TBD, when our development team is using Scrum?
I've been reading Refactoring (2nd) by Martin Fowler. In the first chapter, he shows an example of refactoring a function where he extracts other functions from it and places them inside that function as nested functions. Specifically, starting from this function: function statement(invoice, plays) { let totalAmoun...
We have a monolith C++ application and I consider doing some major refactorings. Since we're not completely ready to go full "microservices only" (maybe in about two years time), I want to structure the new architecture in a way so that the application can be run as both, a monolith with every microservice compiled to ...
I've generally understood the SRP to roughly mean: Each class should do one thing Exactly what "one thing" is is up for debate. However, I've recently seen claims that the entire SRP has been misunderstood and misquoted so severely that its meaning has changed. In fact, its original meaning was: Each class should be...
I have been asked to get involved with a Team that is currently having delivery issues for various reasons. During my review I came across an acceptance criteria on a user story; If you call v1 of the API with Field1 it should fail with a validation message Field1 does not currently exist in v1 of the API, it is bein...
I currently have a solution that requires leadership election for HA. It processes files as they arrive in an SFTP server, and Subscribe to an Active MQ feed; and therefore we don't want multiple running instances trying to act at the same time. I am currently using Apache Zookeeper with the Curator library to manage l...
Recently I read about ISP and wanted to implement it into my project. While implementing my design I think I found a flaw which violates LSP but I'm not sure. Given I have a game project, in which players can walk around and use items. I currently use the interface Item as a base, which has the subclass Weapon, which h...
To explain what I'm trying to accomplish. Sometimes I visit website1.com, here I can download Linux ISOs but it's a bit annoying because it has a lot of ads, some of which are launched via javascript when I click the download button. Sometimes I visit spotify.com but I hate green, so I'd like to modify all the images a...
I am very new to Git and trying to follow along with Git Prodigy by Ebenezer Don to learn about it. I am at the (early) stage wherein I am learning about git revert. I produce the text file prac.txt This is a random text file I then make this my first commit (git add . followed by git commit -m "First commit."), with ...
I need to compare versions of a software. The requirement is that I need to know if a given version is older (smaller), same or newer (higher) than another one. The version format is XX.X.XX where: the first two digits are the major release. Major release can be between 01 and 99. The next digit is the minor release a...
I am working through an example of best-first search on a graph, and I'm having some trouble understanding exactly what the process should be. This is the graph I have: The heuristic values are in the boxes next to the applicable nodes. So from my understanding from the textbook I'm working through, calculating the pa...
I need some guidance on how to send error responses to client from WebAPI controller for an update operation. I need to check if data is changed and if it has duplicate data. I have service class that does database operations. Below is psuedo code Approach 1 CustomerController.cs public Task<IActionResult> UpdateCustom...
I am looking for feedback on a design problem I encountered when processing batches of db entries. The issue at hand is efficiency and throughput of an application. The application looks like this simple pseudo-code // The loop is done outside of the application by some sort of orchestration while (true){ void Mai...
We have a GraphQL server which sends data to the front end client. We have other tenants who will use our sever and host their code. I want to create a system where they all can create any custom exceptions if they want or they can use some of the exceptions that the server can provide like DependencyFailure. Also erro...
Assume we are designing a typical bank account management system. Customers can have one or more accounts. Customers can deposit cash, withdraw cash or transfer money to another account (and, of course, view the balance). If all accounts are contained in the same bank, one could, for example, design a Customer class an...
I'm working on an application which has a feature of syncing records between two environments. For example, a record A is created in environment A. After a user verifies it, the user can use the sync feature to transfer the record from environment A to B. The solution has been implemented using Django API and requests ...
I am trying to learn a little Python by myself and came accross this book Data Structures and Algorithms Using Python Rance D. Necaise 2011 , to get some proper/formal/correct definitions/terminology in Computer Programming Languages. First pages introduce Data Structure and Abstract Data Types , and at some point quot...
I was reading Google's Architectural overview of Pub/Sub and I was curious how publisher and subscription servers were connected. From what I understand: When a message is published, it is stored, and then once all subscriptions have acknowledged that message is deleted. subscription servers can use a pull or push mod...
I am told everywhere that entities are only to represent the data structure, then entities should be mapped to a model and then the model possibly to a DTO. The other way is similar, DTO -> model -> entity. It seems simple, but when it comes to working on a lot of highly nested entities, it is very tedious to track cha...
Scenario: A web application that wants to implement geographically high availability (HA), has multiple web servers in different cities around the globe. Each server is connected to a database in the same city. These databases are configured in an active-active DB cluster, meaning each database will handle its own read...
I am currently developing a feature for my web application that tracks the amount of time a user spends on a specific page. Our backend is built with Django, and the frontend is using React and PostgreSQL as the database. I'm looking for advice on the best practices or approaches to implement this feature efficiently. ...
Suppose I have an application where I can manage clients (just companies I offer my services to) and what services I offer for them. I also have the functionality to create timebookings, which means I can say "I did 3h of Service X for Client Y". The timebooking needs to know which employee did this. Now in the ubiquit...
We have a release cycle about three to four weeks for a new release then a bug fix sprint to make the product stable, then new features sprint to kick off another round of release cycle. What should I, as their developer manager, do during the bug fix sprint when my team members are busy in fixing bugs ? I have tried s...
According to Should we avoid custom objects as parameters?, for example, if I have an object to show: public class Student{ public int _id; public String name; public int age; public float score; } and I need to pass the information of the object to a window to show, passing the whole object as paramet...
Prelude Recently, I helped a friend of mine in coding him a problem for his university Algorithms course, where problems are submitted in Java. I sent him code with good O notation complexity, sequential memory accesses (as I thought) and etc, all the common in C++ world good practices, and kept hitting Time Limit Exce...
I have an aggregate, let's call it Party. For a party, I can have many People which is an aggregate as well as they can exist on their own without the Party. But specifically for the Party , I want to keep track of how much Food was eaten by each person. How can I model this? The Food cannot exist without the People at...
Context: The software development company I work for develops an application which is released with SemVer versions. Typically customers use the last 2-3 minor releases, so for an example if the latest released version is 3.6 there is still a relevant user base using releases 3.5 and 3.4. For these versions, we guarant...
Lets say you have a ItemView and a ItemModel. Would it make sense to have a ItemWidget encapsulating those two, so code using ItemWidget don’t have to deal with ItemView and a ItemModel specifics? What would you miss doing so?
I need assistance with the QueryBuilder that generates OData query. Following is my implementation and it approach has couple of issues If user forgets to SetRootTable then it will cause serious issues. Task.WhenAll since it is a single QueryBuilder instance and queries gets corrupted. Please suggest alternatives t...
I'm looking for a way in C# that finds all the possible combinations with constraints. I've got a list of machines. The machines have capabilities and limitations. I also have a document that defines the starting material and end result. The machine capabilities is a flag enum with cut, print, joint. Constraints are sp...
I have little app that i plan to run behind load balancer, with up to 5-8 instances. Inside the app has service, that needs to generate unique number that has up to 10 digits ( so 1-10 digits) each time user triggers the process. There will be approximately 10-50k invocations of this function per month. In non-distribu...
I'm struggling to (integration) test a component that makes use of an infinite generator. Background: At a really high level, this component is essentially a "middleman" in a kafka workflow. It subscribes to a kafka topic, consumes messages, does some operations on the messages, and re-publishes them on a different top...
I have been reading about clean architecture and following Domain-Driven Design. In all the examples I have found, the interfaces of the repository are defined in the domain. However, it is in the application layer where the repository interface is injected, and the interface is implemented in the infrastructure layer....
I am a student and am currently programming an API in Python. Among other things, it is possible to register, log in, create a user profile with data, etc. I would like to be able to store and retrieve sensor data as time-efficiently as possible. For example, the data from a light sensor. It should also be possible to ...
I was assigned a task to change the communication mechanism between two parties, from Azure Event Hub to Azure Queue + Blob Storage. On the way, I thought redesigning a bit the components to make it easier to understand what the repo does/what is going on. We are talking about a Service Fabric Application, with a coupl...
I have an event, let's say order.placed The payload consists of some general information about the order and 3 confidential fields. For example part of the message should only be visible to consumer A, part to consumer B and part to consumer C. Does any pattern exist to handle this kind of requirement? I considered enc...
I know there are already some questions about replacing if else with polymorphism, for example: Applying Replace Conditional with Composition in functional programming Is it wrong to use any type of parameter to determine behavior? Should conditional logic be always coded via type system where possible? which the follo...
Let's say that I have a class with a service that is going to be injected at runtime: class Thing { private magic: IMagic; // Magically injected service public doStuff(){ // Do a lot of stuff const value = this.magic.performFireworks() // Do a lot of other stuff with `value`, eventuall...
A test program should post a json object to a rest service OrderRequest and receives an OrderResponse. The test program should tests against the quality assurance stage (qa) and against the production stage (prod). type Endpoint struct { Login string CheckOrder string } // https://go.dev/play/p/3vCgU2rA7iR...
I'm not encountering any issue in prod or anything, I'm just reading about Kafka and I'm curious about this case. As I understand, A producer sends messages to the leader. The replicas copy the messages and inform the leader about how far they have read up. Let's say I have sent 6 messages to the leader and the repli...
I'm studying architecture patterns and I don't understand which type of scenario is more preferable to use clean architecture or hexagonal architecture. Is there something like that? For example, "If my application has a lot of business logic, is it better to use clean architecture than hexagonal architecture" or is th...
Is trunk-based development (TBD) viable for development of software where versioning, compatibility, long term support and service level agreements (SLA) play a big role for business (e.g. libraries, frameworks, drivers, SDKs)? Some context I'm interested in TBD in context of different types of software projects. The p...
I have a web app which authenticates the user using an external identity provider (Microsoft Entra with MSAL library). This give us an access token to access our API. After authentication (so, we already have the token), the user must select the company he wants to work with. The "company list" shows only those for whi...
I've found that many codebases in large companies degrade over time, only adding new features and never improving the design of the codebase. Gradually, these codebases degrade to what is considered "that legacy system no one wants to work on". However, I do know that one can refactor a code base: "improving design wit...
I'm developing a data pipeline in Python. We receive a variety of different types of data set that we need to process (e.g. xml, json, csv and some Excel workbooks) - where processing involves parsing the data into a usable structure, some data cleaning, removing some sensitive info, and uploading the output to cloud s...
I have a project where there is a primary, high-level, opaque struct with many functions that operate on it. Maybe I am simulating a CPU. How might the corresponding source code be organized? One way to organize the source is to put the entire interface in one ".h" file and the definitions for all the functions in a si...
I'm working on a library of C++ wrappers/bindings, for another, C-ish, API. The C'ish API has a "launch" function, which, among other things, takes a launch configuration structure (well, sort of, I'm simplifying things). Not every point in the space of values for this structure is valid. For example, it has a num_widg...
I have an algorithm I am trying to implement that has steps 1 to 5. There are several different ways I could implement each step. Each calculation step is essentially just an astronomy calculation, and I could either depend on any one of the astronomy libraries or implement my own astronomy calculation. My current desi...
In the context of a software update system, suppose we have the following: a.tar: an archive file containing an old version of an application b-a.patch: a file containing the binary difference of the old a.tar and the new b.tar (from bsdiff) Both files are present on the same system, and the authenticity and integrit...
I am fairly new to MVVM. I am writing an application in which user creates a study for a physics simulation, inputs some data, runs the sim, and then views the results in graphs and tables. The application needs to have Save As / Open functionality to save the study into a single file and load it back after restarting ...
I was tasked to create an API client library for our already existing API. I tried to research some ways how to approach this but couldn't find anything. Are there some best practices how to build such client library, or are there some already existing clients from which I can get some inspiration?
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...