instruction
stringlengths
34
36.1k
I'm looking for advice on how to design the data model for a project I'm working on. I'm not really sure where to ask such a question. I've been using StackOverflow for years, but this problem is a bit too abstract and theoretical for that site. I hope found the right place here. I will first try to explain what I'm tr...
The traditional non AI software with if-then-else and loop statements can be fully controlled. In contrast, machine learning software behaviour is unpredictable since the developer cannot control what the software learns from the data. In particular, large language models (LLM), which are a form of neural networks, are...
I have an app with "clean architecture" classic layers: Ports (such as HTTP, GRPC, GRAPHQL resolvers) Services (CRUD methods and others) Adapters Domain My app has of course multiple "models" such as: Player id: String (mandatory) firstname: String (mandatory) lastname: String (mandatory) age: Number (NOT manda...
I have a server(API) written in Flask and a client(mobile app) written in React Native. The application allows for logging in with either email/password OR with Google. The Google authentication flow works as such: User presses on the Sign in with Google button; Frontend sends the user to the API endpoint /api/google/...
I'm building a reddit clone on top of software that must incorporate a legacy neo4j graph database to track user actions. I also want to use it to store the comment/post data. Assuming this new app is basically used like any other content aggregator site, would it be better to store all comment data in each node or onl...
TL;DR: Using GitFlow, which commit do you tag to identify the build of your next release? If you tag the merge commit on main, you'll need to rebuild and deploy something you didn't test on QA (and this contradicts "build-once, deploy anywhere"). If you tag the last commit on the release branch, your commits on the mai...
We are developing a multi-user web-based application, where the users can join a "room" and a complicated handshake has to be set up between them, to be able to use a library on each frontend side. This session/room logic and the handshake that has to be set up goes through a backend server with WebSocket communication...
I did research about this and I'm facing with two challenges: how to handle version deprecation in my CI/CD pipeline, when we have more than one major versions officially functional and others deprecated. how to handle documentation of the project The project is a .net web API(uses Swashbuckle for docs) that uses Git...
I've been working at this company for about a year now. it's a growth company working in B2B. I'm one year out of university, with a major in computer science. I work in the web team, using an Angular frontend and node as the backend. Throughout my time here it's always irked me how little effort seems to be put into t...
I have lots of devices, each identified by a unique UUID. For each device, I have one or more timeseries data (potentially up to millions of entries). What's the best way to store these entries? Whatever I do, it seems to me that: either I store the UUID of the device with each time series entry, which wastes a lot of...
I make sure when designing software/firmware to make heavy use of dependency injection so that different pieces of the application are not directly coupled to one another. This also allows me to (potentially) unit test each piece of code using mock dependencies. However, the dependencies that need to be passed into co...
I am designing an aggregate that has list of keywords as its property, and it has constraint that two aggregate cannot have same keywords as its property. I use repository that has save and saveAll method when persisting aggregate, and each run in a single transaction. And Factory pattern is used when creating an aggre...
I'm converting some old MVC/Service code to CQRS/DDD. To create a user, I need to: call an external service to create an account in that system, and retrieve the guid associated with that new external account. create my local user domain object (which requires the externally created guid) - and store it in the local d...
Behavior-driven development is meant to be used at the business/user level. However, I find the keywords "Given - When - Then" a good format for technical stories as well, but I am very green, and so maybe I'm missing something? Is there a better format to track technical debt, or tasks under user stories?
I have an offline-first mobile app. The user enters data, data is saved into local SQLite database. The server has Postgres database. I need to build a two-directional sync strategy that keeps data on the server and on the client in sync. Here's what I want more precisely: Bi-directional sync. Small data volume (hundr...
Our codebase has a typical base-class with a ton of sub-classes. The base-class already has many default functions for the sub-classes. However, one particular function has the same verbatim implementation in almost all of the sub-classes. (Each of the rare cases has its own unique implementation.) The rationale I hear...
I am an engineering manager and I manage an engineer who is responsible for a backlog with long lasting development tasks and many bugs arriving a few times a week. We work in scrum sprints but when a bug is arriving we prioritise it over the sprint items. Lately the developer is complaining that they are constantly in...
I have a good understanding of when coroutines in Kotlin are superior to threads. I know that coroutines are lightweight and are great for massive concurrency when, in contrast, spinning up lots of threads is costly in compute resources, memory consumption, and possibly other ways. I also know that coroutines are ultim...
This is a simplified representation of the existing data structure I have in my code (The actual data structure is composed of classes), the data of which I need to display and modify via multiple views: struct StopData { QString name; int id; QList<Amenity> amenities; ... } struct Amenity { QStrin...
I took over a development team working on life-safety critical software earlier in the year. The product has been in development for about 8 years, but the current team has only been working on the product for about 2 years. I’m not a software engineer by trade, but have been a system administrator for a ~300 person or...
I'm a novice in architecture. Now I’m reading Clean Architecture and I don’t understand one thing. I'm wondering at what stage should I create components? Before any design or when I already have some design and implementation, something like this: P.S. It seems to me that the answer is somewhere in the middle. Compon...
I'm working on adding unit/integration tests to an existing project (Java/Spring Boot) and I've been investigating on how they are "separated" in order to cover the test cases and how to focus each type of tests based on what they are written for. To put things simple, my two questions are: Is it a good strategy to co...
Given a system where users can access different services through the API for conducting business transactions, I am currently working on integrating a read-write lock into the system. One approach I am considering is manually adding the locking logic to each method within the service: class SomeService { func DoBus...
A pattern I have noticed in many big C and C++ programs - including Microsoft Windows (REG_SZ type in Registry) and Valve's Source SDK (names of practically every string variable) - is that "sz" is used as an abbreviation for "string". Why is it "sz"? What does the "z" stand for? Where did this naming convention origin...
I have a wide CSV file of about 350mb, and want to load it into a SQL database and properly model the data to make it easier to use for analysis. I could split the data into tables with python and then loaded into sql Or load the file into the database as a table, and then split it using sql. What would be the standa...
I have several million booking rows in a table and would now like to save the totals of the booking amounts in another table depending on the customer, account no., product, etc. Should this necessarily be done at application level, or can the database (MySQL InnoDB) also do this reliably with INSERT INTO SELECT? I cou...
If a lambda is frequently used, it is considered to reuse the same instance instead of creating new instances repeatedly. How can I minimize the number of captured variables in lambda expressions?
I'm writing a C++ class, CBookSpellDef which has the following methods: int GetIndexOf(const char *psz); char* GetNameAtIndex(int index) { return m_spellTypes[index].szName; } char* GetWeaponNameAtIndex(int index) { return m_spellTypes[index].szWeaponName; } int GetBasePowerAtIndex(int index...
In my current monorepo structure for frontend, this is how it looks: apps\ jira\ confljuence\ packages ui utils\src (contains common utils like useDebounce.ts, isEmptyObject.ts, etc.) From what i have seen in most monorepo examples(open source) people put only non business logic stuff in utils package. I ne...
I'm refactoring a common web app (not spa but traditional server side html rendering). The design/code organization follows more or the less the Clean architecture concepts (ie: controller calls a use case layer then pass the UC response to a presentation layer). The technical environment is PHP/Symfony 6. about vocabu...
I am making a .net Maui QR code business card application and the application will not have authorization features such as member login and registration. And my app needs to be able to create business cards for my user, store those business cards, and save new business cards. How can I provide this feature? Is it possi...
Update: Forget the 'best' way, any way to start with is good enough. I am new to this and figuring it out all by myself is taking too long. I don't even know where to start. I am new to this and unsure where to start. I have 5 ML models deployed as 5 microservices, each with its own Docker image. Together they form a p...
I'm trying to practice BDD by applying it to a simple problem—in this case, the flocking algorithm, better known as "boids". Before any of the rules (cohesion, alignment, etc.) comes the most fundamental behavior: movement. The rules mutate a boid's velocity, but that means nothing unless the velocity mutates the boid'...
This question is language/framework agnostic. EDIT: The comments and answers have highlighted how different languages approach events differently, which made me realize this question isn't really neutral across languages or frameworks. To clarify, I'm using Vanilla JS, and my components are built with Web Components. W...
I've been at my current job for about 4-5 months, mainly working with Go, and I have no prior experience with Kafka. Before this, my background was in JavaScript, Node.js, React, etc. I recently got a simple task: write a Kafka-based agent that listens to a topic and stores all events from this topic in a database. I b...
Not sure whether this is a fitting place to ask such a question, but here goes... I learned about simple machine learning and supervised/unsupervised training back in Uni, where I specialized in machine learning, but haven't been able to utilize/practice that in my day-to-day work - which I am trying to do now. What I ...
I have been working on launching high-altitude balloons (HABs, or weather balloons) and I have been using LoRa to enable long-range communication with my balloons. It's been great and pretty reliable, but in the best case, I get about 50 kbps and usually a bit less or a lot less when we start getting to really far hori...
I've set up a ternary operator in place of a pile of if-else's, the final expression being nullptr in order to finish the loop, like so: int menuSelect; std::string operation=""; (menuSelect==1)? operation= "string1": (menuSelect==2)? operation= "string2": (menuSelect==3)? operation= "string3": (menuSelect==4)? opera...
So I am working on this mobile application using MAUI, which is backed by a Rest API in ASP.NET Core. I want to be able to use the app offline, and the user can create/edit some data. This data is store in a SQL lite database, locally on the device. But it has to be synced to the Rest API as well, so the user can get a...
I'm a beginner, but competent at code and have some setbacks like this where it doesn't really matter- but I like making it easier and legible to understand my code. Anyways, yeah. I just have problems with three word sentence fragments - should they be amountOfColors or amountofColors?
When Visual Basic came out, it was revolutionary for its drag-and-drop GUI designer, allowing users to quickly create GUI programs. This video shows Bill Gates introducing it in 1991. Did drag-and-drop GUI designers exist before this? For example, did Apple have a similar tool to design GUIs for the Macintosh 128K, or ...
I was going through this blog - https://www.notion.so/blog/data-model-behind-notion Which talks about how each page can inherit permission from parent page. we use an “upward pointer” — the parent attribute — for the permission system. Take for the following hierarchy: Here if at Root page 3 users have access rights...
I am developing a package that requires some very large (>50 Mb in some cases) artifacts to work for some of its features. This makes distributing this package annoying, as if I include these artifacts inside my bundled package, users will have to install a huge dependency even if they might not even need said artifact...
I'm trying to model a specific domain using DDD techniques and have some doubts. To better contextualize, a brief description: It's a domain of deliveries and delivery confirmation. We have two main actors: Customers who bought products and need to track their deliveries Drivers who receive travel schedules with mult...
Anybody have advice on splitting up a large SQLAlchemy model into smaller parts? I have a ~2000 line model called Article that is becoming difficult to manage. We often have to scroll and scroll to find code that needs updating. It's doing four main things, with each of these methods calling smaller methods, all on the...
I was reading these best practices for Angular project specifically for understanding models and DTOs. What I have understood in general from different resources and the above one also is that We should have DTO to match exact response structure coming from backend APIs We should have model classes to use to show data...
From what I've read, domain services typically don't import or rely on Repository directly in theory,The responsibilities of domain services focus on handling business logic and coordinating interactions between domain objects. But in actual development, I found that I had to call the data warehousing interface in the ...
For instance, I've started working on a new feature and created a featureX branch. Later, we decided that we no longer needed the feature. What should I do with featureX? I see value in keeping the branch around in case we change our mind on it again. My strategy is to push that branch back to the remote and delete it ...
I made some changes that, after testing, I decided not to use for now. Thus I don't want them in the main branch. However, I don't want to discard them altogether (maybe I will need them later?) What should I do? The easiest option is to commit them and immediately revert (don't laugh). I suspect that what I am suppose...
Abstracted problem I would like to be able to quickly refer to some (most likely non-hashable) objects. At the same time, I would like them to be aware of their own identity. The 2-way search should be consistent, so at no point should an object give out an identity, which would return another object, had someone reque...
I'm currently implementing clean architecture in my project. My application includes various types of communication protocols (TCP, HTTPS, etc.) implemented in the infrastructure layer. These communication protocols are responsible for handling incoming and outgoing network communications. I need to process the incomin...
We have a large(ish) real-time embedded system. It's VxWorks, if that makes any difference. It has some C code in DKMs, but is 95%+ in C++. It has absolutely no exception handling, nor Posix signal handling. It is multi-threaded, so if one thread/process/subsystem dereferences a null pointer, or access a non-existent v...
I have the following use case. We have both a frontend application and a backend application. Earlier, events on the frontend application directly call the backend application. Now we want to introduce an orchestrator (like Camunda or similar in-house product) between the frontend and backend applications. Following wi...
Consider Chess as an example. Say, we have a lot of domain objects that are alike, in this case chess pieces. I have two proposes to implementing the behaviour of chess pieces. Both uses the following interface. interface IPiece { // ... shared behaviour bool IsValidMove(int targetX, int targetY); // ... mo...
Hobby coder here, so please be gentle! My coding is taking me into the necessary realms of architecture due to increasingly complex apps. I'm wondering how to structure my solutions which will involve separating off layers to separate libraries whilst implementing the MVP model (specifically, the 'observing presenter s...
From Ch 12 (Resiliency) of the book "Building Microservices" In the context of how much resiliency is too much resiliency How long should various operations take? It can be useful to measure this with different numbers of users to understand how increasing load will impact the response time. Given the nature of networ...
I'm working on designing a shopping cart system that respects the single responsibility principle. However, I'm facing a challenge when it comes to handling cart creation and updating separately. Scenario: When a user logs into the website and adds products to the cart. Currently, the "add to cart" operation also impli...
According to Eric's definition of entities: "An object that is not fundamentally defined by its attributes, but rather by a thread of continuity and identity" Does that mean apart from all the attributes every entity should also have some sort of status enumeration in them? e.g. Order entity going to have OrderStatus, ...
As a consultant working for multiple companies that are using maven multi modules I have made the same discovery with all of them that I find strange. Lets say they want to build a webapp for a hospital that manages staff and patients. Assume that they are separate domains. The project would look like this: hospital ...
I am developing an API backend using ASP.NET Core Minimal API (.NET 7) with Entity Framework Core, HotChocolate (for GraphQL), and a Microsoft SQL Server database. I've encountered a specific challenge regarding data mutations and would appreciate any guidance or suggestions. Problem: In my application, users can submi...
I am trying to design a system and bounded contexts. I have 3 microservices: Security, ProductsCatalog and Customers. Each microservice own its database. Security is a cross cutting concern used in other 2 microservices. Question: How to implement a search that depends on Security microservice? For example, there is a ...
Serialization and deserialization in .NET applications can be achieved using several libraries, e.g. Newtonsoft.Json System.Text.Json Assuming I'm developing a new application where I want to use Newtonsoft.Json but I want to keep the flexibility to switch to System.Text.Json (or another library) at a later point in ...
I've been wondering about code expressiveness vs. conciseness lately. What I mean by that is that a lot of modern programming languages offer features to express statements in a very short manner, which is cool, but I feel like it can also make it hard to read sometimes. At the same time, working in a team with others ...
I'm not sure how common of a scenario this is, but what are some approaches to creating associated entities before you have the actual main entity they're supposed to be linked to? (basically having separate endpoints for the associated & main entity creation, with the associated entities having to be executed first, a...
I know you can't inherit static methods, and it seems the consensus is that if you feel like you need to, you're doing something wrong. However, I don't know what the alternative is in my case. Please see the abstract example below: public abstract class A { protected static int defaultX; public int x = def...
Client sends request to deduct his account balance for registering with a service. balance=balance-fee Server takes a lot of time to process the request. Since server was taking lot of time, client is notified by a middleman between client and server (the one who's negotiating with both client and server), "Timeout"...
I'm writing a program in Java where I need to represent the position, scale, and other 3-dimensional properties of objects in a world using vectors. I can use either of these two approaches: Represent vectors as an array of doubles with 3 elements (procedural approach) Represent vectors using a dedicated class, with d...
I'm creating the UI for a "Point of Sale" type page. You can add orders, grouped orders, and custom items to your transaction, and it should display these in a list so you can see what you have selected. They all have the same basic details: Type Description Price But they also have major differences. E.g. Orders mu...
We are finishing up a long (over 1 year) project to retire our monolith. We have been moving pieces of functionality into microservices guided by domain driven design. So far we have been leaving the data model unchanged (we have been moving the tables owned by microservices into their own schemas). My question revol...
In UML statecharts, an event may how zero or more "parameters" (i.e., additional data associated with the event). The classic example would be a key press event with a parameter containing the key that was pressed. When designing state machines, I often come across the following scenario. An event with parameters is re...
I have a repository which reads and writes to Firestore, and some tests to make sure data is sent and comes back in the correct way. In order to test this I added a protected function which returns the root collection I'm working with, i.e. protected open fun users() = firestore.collection("users"), which is overridden...
I came across a piece of legacy code, almost on the line of this (sample) int foo() { try { int id = generateID(); if (isIDUsed(id)) throw id; return id; } catch (int id) { std::cerr << "exception: Used Event ID Generated" << id << std::endl; } } Here generateID() and isIDUs...
What I mean by "closed class hierarchy" is a set of known base/derived classes used only for an implementation of something with no public API, i.e., the classes are not meant to be derived from by users. Another possible term might "non-extensible class hierarchy." But is there a proper term for this?
I am creating an API proxy that acts as a bridge between our frontend application and an AWS opensearch server. This proxy has additional features such as retries and timeouts. One of the features I'm considering is request body validation. This API accepts 2 types of data: JSON when Content-Type is set to application/...
If there are many tasks in the backlog and the product owner keeps adding them, some of the tasks become outdated and in practice they are never implemented by the team. Why don't we borrow some techniques that are used in thread scheduling to prevent thread starvation like: aging – task's priority could be automatica...
Let's say we have a group chat in a chat app build with websockets. And 3 users (A, B and C) chatting in that group. All 3 users send their message one after another with an interval of 1 second (it looks like the time is in h:mm format but it doesn't matter in our case): The server recieves those messages in the same...
What are some commonly used strategies when it comes to divide software into modules, other than there should not be any cyclic dependency between any modules? Some ways I think of Group everything that relates to a set of related classes into one module. I could have one module for 1d data (curves), and one module fo...
In Python there are basically two ways to get a value from a dictionary: dictionary["key"] dictionary.get("key") Is there any - maybe historical - reason for this behavior? I sometimes stumble upon this while switching from JavaScript frontend development to Python backend development forgetting that dictionary["ke...
Given that there are no checked exceptions in Kotlin, are Result types the correct way to indicate an exception occurred to the caller? For example, I have the following function in my code: suspend fun addUserToSignInHistory(user: User): Result<Unit> { return try { preferencesStore.edit { preferences -> ...
This is a conceptual question about whether my specific use-case warrants the use of an asynchronous API. Language: Python 3.11 Framework: FastAPI (ASGI) I believe I am confused about what an asynchronous API really means, differentiated from asynchronous processing (multi-threading, event-loops, futures). I am under t...
Is it possible to design a distributed system to generate unique ids where there is a requirement that every generated id is guaranteed to be unique with no possibility of collision? I didn't think that this was possible, given the fact that there is a finite number of ids which can fit into some structure. So for ins...
Let's say you are running a query on your database. In development and staging, where the amount of data is small, everything looks good. Unit and integration tests are also fine and the logic is correct. But when you get to production, where the database is much bigger, all of a sudden it turns out the query is not ef...
A scenario often arises when attempting to make some existing code reusable. I introduce an interface to represent the commonality between some new feature I'm implementing and some existing functionality, but I become stuck when trying to access the existing concrete object. Hopefully the following C# example can expl...
I am designing my next project, which will do various domain-specific tasks, but all that will be controlled and used via a generic crud web app. I have been professionally using Java with Spring for over 3 years now with the usual corporate applications, but these domain-specific tasks absolutely have to be done in Py...
Merge Sort contains basically two important routines: (i) split (ii) merge. I get the general idea. But I dont understand how this is more efficient than some random bad sort algorithm, like selection sort, for example. I kind understand the maths behind, I know why one is O(n*lg(n)) and the other is O(n²). I know lg32...
We are a small software team with 6 members. We are working on different software projects in our company. Before I joined the team no version control system was used. It was/is my task to reorganize the team and daily work to use a vcs (git with own Gitea server). I'm now at that point where I have to find an appropri...
Suppose I am developing a class which implements some high-level application logic. I want the "configuration"/"attributes" of this logic to be modifiable at run-time (with some default values). Some attributes may be read-only, others may be read-write. I am going to use a custom "networking" layer as an example: cl...
I am writing a little C library for the Raspberry Pi for controlling 433MHz transmitters/receivers. While receiving data the whole application would block, so I decided to put this code into a separate thread and synchronize it with the main thread. #include <stdlib.h> #include <stdbool.h> #include <time.h> #include <...
I am looking for a concept that handles the needs of some data to be distributed in several environments (lets say we have dev, test, stage and prod). Example: We are setting up planned outages of banks we are using and share that information through REST API with our clients. Now banks basically do not provide sandbox...
I have a class hierarchy of elements (more static) with different operations on them in another class hierarchy (more flexible). During execution there is exactly one element given, and based on it's type I want to perform a given operation. Instead of using some chained conditional like if (elem instanceof ElementA) {...
I'm trying to wrap my head around the ASP.NET Core Configuration system. If I understand the default configuration correctly, non-prefixed environment variables will override appsettings.json entries. For example, if I have an appSettings.json file like this { "SmtpServer": "myserver.example.com" } and some other,...
We have a huge amount of queries hitting our API that request a minor or major extract of some huge files lying around on our mounted hard drives. The data needs to be extracted from the files and processed before handing it back to the customer. My goal is to make this operation as blazingly fast as possible. To piece...
I want to collect a lot of files (file data + metadata) from local servers to a central server. Files are important, need to ensure that no files are lost Local servers: implement a collector to collect files, 10k files/day/local server Center servers: minio storage: save files ingestion service: provide an API to re...
I am working for a medium-sized development and construction company and we are looking to upgrade our data and BI. Currently, all project data is managed via Excel (data, project management, and performance) while financials are captured via Acumatica. We are in the process of adopting a true project management system...
I'm building a ToDo list while practicing in different patterns and adding more complexity to the project. The problem which I'm currently facing is to how to apply (and later use, validate and enforce) different permissions for different classes of users (PM, Dev, Admin) and for different users of the same class. I bu...
I am looking to create an application which will have following architecture: Site Database (Which will run on-prem or cloud). If multiple sites then multiple database instances for each site. In other words site is tenant. Cloud central database -> which will retrieve and push all data from sites used for company rep...
We are producing configuration files for a production system. The configuration files have a dynamic set of variables. Optional values and other values that only need to exist based on other values. The system using these configuration files are depending on the parameters coming in the expected order. The current syst...
We have a internal system (lets call it system B) that responds "No" as a response to a request from external-facing system (lets call system A) based on elapse of 48 hours from earlier request if a token was not attached with the earlier request. . More Context: We have an external system which receives requests from ...
I'm building an application that allows the creation of users. These users can have profiles which define their permissions, as well as be given specific permissions. Now I'm struggling on deciding where these permissions should be stored. Of course they will be stored in a database, but when a user makes an API reques...
Suppose an organization is developing an enterprise assistance and management platform with instant messaging, video conferencing, file cloud, online documentation, process approval, and more. The implementation of each function requires a complex technology, so how do you identify the subdomains of the platform? Or to...