instruction
stringlengths
34
36.1k
I am developing a web application using Java servlets, and I would like to know what the software development community thinks of the following programming practices: Use static member variables for the names of input parameters. I created a separate class that contains static member variables to store the names of in...
I recently had a project that I took me 4 months to do , I hit some very significant bugs that where impossible to track down. I said this code is absolute garbage and started from scratch, drank a monster and got cracking, people tried to distract me but I persisted. I sent the code to QA and I personally tested all t...
I am building 2 REST microservices: ParentService and ChildService. I need to build endpoint to fetch all Child resources related to specific Parent, so I have these URI's as options: GET /parent/{parent_id}/child GET /child/parent/{parent_id} POST /child Body: {parentId: 123} But neither seems to be proper solution...
EDIT: more direct situation I need to design a program that will create particular objects and run computationally intensive procedures using its fields in order to update other fields. When a procedure completes, other procedures can now be launched using the new fields. These objects are saved to disk and used in lat...
I'm working on building a library in Java which could provide the ability to record runtime data. For instance consider the below code: public interface ItemElement { public int accept(ShoppingVisitor visitor); } public class Book implements ItemElement { private int price; private String title; ...
We want to install Kafka Kraft cluster on 35 machines ( machines are DELL physical machines - type R760 And OS is Linux RHEL 8.6 version ) Since we are dealing with Kafka production cluster , we want to understand what is the best Practice and the right approach to install the machines and configuration The question ab...
Could someone explain to me if the relation in this class diagram is a "dependency" or "association" relationship and why? I cannot edit the picture. The terms translate into English as follows: Pessoa = Person; Agencia = Office; Conta = Account
I recently worked on a project where the team were writing lots of unit tests for hardcoded values, for example, unit tests that test the value of a string constant. The justification being that they protect against accidental change. It feels like overkill to me, we had hundreds of tests and they never once caught an ...
Please help me understand why, in this diagram, "Validate User" is considered a use case. My understanding is that to qualify as one, a use case must: Be initiated by an actor; Represent the actor's goal; Deliver discernible value to the actor. The use cases "Withdraw Cash", "Transfer Funds", and "Deposit Funds" all ...
Trying to understand and compare synchronization primitives, like std::future/std::promise, std::barrier and std::conditional_variable - developing an intuition for which one to use when exactly. I have this scenario where there are two threads synchronized via a flag. Basically, A expects B to signal upon setting a fl...
Quoting this article - The Other key differences: gRPC vs. REST section (client server coupling): Client-server coupling REST is loosely coupled, which means the client and the server do not need to know anything about the other's implementation. This loose coupling makes the API easier to evolve over time. This is be...
I've come across a scenario where data in one table is related to another table but referential integrity doesn't seem to apply as I would usually expect. This is because table x uses data from another table y but y can change independently from x. This only happens in some scenarios related to the state of x. Consider...
I am learning programming on my own following standard programming language textbooks. I come from a math background. I learned C on my own, but never really got to the more advanced portions. I tried taking a coding course in college for CS wannabe majors who have no coding experiences. They keep talking about the ...
For updates on a dashboard, I need to decide to make an extra api end point which creates a message in SignalR or let some kind of message broker (filewatcher1) do that. What would be good architecture? Context I've created an api which reads and updates data of an ERP. The ERP has its own client (UI) where users can u...
I've developing a .NET Core library meant to simplify the configuration of the authentication within our SSO system. It will expose two methods to be called in the Program.cs (or Startup.cs) of ASP.NET Core web apps: public static AuthenticationBuilder AddFederatedAuthentication (this IServiceCollection services) publ...
In a Java Spring API, I'm implementing GeoJson Conversion Service to convert different types to geojson, I have GeoJsonConversionService interface, and one implementation is FileGeoJsonConversionServiceImpl class First question: should the service name indicates the "action" or the "actor", which means should it named ...
We are working on a ubiquitous language; however, there are different terms used for marketing purpose and one used for product team and engineering team. The marketing team's term is more for PR purposes. Wondering in this case, is it OK that we have one terms that is specifically for marketing team and one for produc...
We have a large code base with lots of workflow data (camunda) that does this: Create a reporting event in the codebase Give it a code + payload Put the item on a message queue Consume queue elsewhere using lambdas Write data to the warehouse Whenever the workflow changes, new reporting events are written. Start/End ...
My team and I are beginning to mock our API responses in our iOS app so we don't have to worry about our backend being up when testing. I have conditional compilation directives based on the SWIFT_ACTIVE_COMPILATION_CONDITIONS flag, specifically DEBUG MOCK_SYSTEM. This flag controls whether my code uses mock data or se...
Does it make sense to organize screen resolutions? I write a lot of selenium tests, often which I need to choose a resolution for the browser. I ended up creating a dictionary with some of the more common resolutions I need to test, but I've never been happy with it. DIMENSIONS = { # 4:3 "1024": (1...
I have a situation involving a parent component, children, and async fetch operations, and I am wondering how to best structure it. The current code structure I have is as follows: I have a parent component with a textbox. When the user types in the box, it triggers our debounced API call. useEffect(() => { debounced...
Suppose I have the following client code: using System; namespace InterfaceCompositionUml { internal class Program { static void Main(string[] args) { MyInterfaceImpl x = new MyInterfaceImpl(); MyClass y = new MyClass(); x.MyProperty = y; Console.WriteLine(...
I have a question about encapsulation and I read these two topic (this & this) but I got more confused. I've been reading Head First Object-Oriented Analysis and Design book and I'm trying to learn oop. in one of the pages of this book, I've read these lines: The idea behind encapsulation is to protect informationin o...
New to a software engeneer job and I am kinda blocked on the way to go with my new project To explain this in a scheme. I have a source of data in a custom app that is for most part of the time the result of a stored procedure. Here is a path (Fictional used as an example) of the path that the data had to do before go...
What is a good way to indicate in programming that the sequence of digits you see is not a value you can do math on? I use a lot of numbers which aren't "numbers". From account-numbers to patient-id numbers country codes to the codes for human sexes. What I want to prevent is that others put those "numbers" into an int...
In an app I'm working in there's a service class(among others) which is used just to call methods on other classes. Recently I've had to work in that area and add another method that does what all the other methods do, call other methods from other classes. Arguably, this whole class shouldn't exist, but that's another...
Let's say my domain has a User Entity that has a many to many relationship with itself representing "Friends" public class User { public int Id; public IEnumerable<User>? Friends; } In my application layer, I have a service that makes 2 User friend together and the only requirement is that they are not already...
TL;DR: Should the domain layer span the entire breadth of the app such that everything can be simulated, from point A to point Z, or may the application layer be used as the orchestrator and serve as the glue between modular pieces of domain logic? I read the first 100 or so pages of Eric Evans' book, where he describ...
My organisation is adapting a new SDLC process, and a part of this is to force engineers to map acceptance criteria (AC) to unit tests written for each user story in the pull request (PR). To satisfy the enforcers of this SDLC process, our team wants engineers to manually create a table in PR description to map accepta...
In my organization, we often have meetings to discuss potential points of system failure, prior to implementing much / any of the actual code. This helps us to identify points of architecture, and define test cases. We incorrectly call this "GameDay." I see project management has the term "premortem" which identifies...
During development of libraries (mainly for use in internal projects) I have come across the "problem" of how to design them in a generic way. I am going to demonstrate with an example library that I have implemented and use in code. But first, here is a summary of the ways I know to "distribute" a library in C++: St...
In a C# ASP.Net Core Web Application I have a Domain Model CentralDesignObject made up of many component objects & properties, producing a significant amount of derived/calculated values. This CentralDesignObject includes a reference to a DesignType object. This DesignType determines various fundamental characteristics...
I read an article about that using an interface for an entity is an anti-pattern for these reasons: Your interface signature is identical to your class. There’s only one implementation of your interface. Your entity has no behavior to abstract, yet you’ve created an abstraction anyway. But if I have multiple entity i...
I'm trying to implement LOGO with a physical turtle. I got all the basics done, but I got completely sunk when implementing the "Window" mode. Original LOGO had 3 modes: "Border" - the turtle bumps into border of the screen and stops there, "Wrap" - the screen is a torus, turtle rides out the left side of the screen, r...
I am trying to improve the architecture for my React app project that has grown in size lately. I'm looking at Hexagonal architecture and Clean architecture, and I couldn't really see the difference between them. In Hexagonal, there are main elements like "entities -> port -> adapter". In clean architecture, there are...
This is the node for a tree class Node { public: string name; map<string, string> attribute; Node* parent; set<Node*, customComparison> children; }; Where customComparison in the line set<Node*, customComparison> children is a custom < operator I'm trying to define for Node* objects for use in the set data...
Say we have a function of the form def func(num: int) -> int: num = num + 1 num = 2 * num num = num**3 return num and let us act like each line is a long computation so that we want to break down func into several functions. For example, def _func_a(num: int) -> int: return num + 1 def _func_b(num...
Coming from a math background, counterexamples are equally, if not more, helpful to me for understanding concepts than examples. I've seen many, many examples of when and how to use the SOLID principles, but I am wondering if there are some good examples of when enforcing these design principles is a bad idea. More con...
I have an object with fields like ID, CODE, NAME, etc., and it has its own database table with each field. And I am working on implementing the REST API for this object. I want to expose all these fields but also the additional field TYPE, whose value depends on the CODE field. If CODE is in a valid list, it will have ...
For the following component, how would I extract the unit logic to allow for composition? In my actual app I am trying to reduce the amount of logic encoded in the component and I have decided that the unit logic (prepend or append, the symbol, how to format the value) does not make sense to be embedded in the main com...
How can I make DRY (lacks repetitive patterns) code that also avoids inefficiencies from using intermediate values in a calculation that might not need to be used? Here is an example: In this code, I am using an octree to store a region of 32x32x32 voxels, and I need a function to get and set any given one of the voxel...
In my experience, it is customary to place local variable declarations at the beginning of their scope. Several questions in this forum ask whether this needs to be so, and their answers tend to agree on that variables should be declared nearest to their use. This answer suggests a goal of scope minimization, but does ...
I have this survey software that I'm writing and I'm wondering what would be the best design for my requirement. I'm going to simplify it as best as I can. I have these entities: class Survey { public Guid Id { get; set;} public string Name {get;set;} public ICollection<SurveyQuestion> SurveyQuestions { get...
I am new to DDD and I am having trouble structuring an object. I have a cart, where I can add products to it. Each product has some properties like image, title, price, etc. Whenever a product is added to the cart, the database stores this relation in a separate table, called cart_products. This new table allows me to...
I am a frontend developer (currently working with Vue and TS), and I have been searching for better organization of the frontend code and recently I got to know DDD a bit. I know DDD is mostly used for backend, but since it has some very nice ideias to it, I decided to give it a try and implement a little bit of fronte...
Semantically, C++ std::optional, Rust Option<T>, and other optional/nullable types represent a value that can be present or absent: you have to handle both cases, or you can opt-in to crash. Is there utility in a type that represents a value that doesn't exist yet, but needs to later on in execution? Or does such a th...
I am quite new to design software and especially graphs. So I am working on a full-stack app with a back-end built on FastAPI (python) et front-end on React. I need to create 4 graphs on a single page on my React app. Each graph is a time-series graph (simple) but with 3 millions data points (every 3 seconds since a co...
Introduction Hi everyone, in my company we are using microservice approach and of course are trying to do it as correct as possible. There is a new requirement coming up where I have laid out a proposal for an architectural design. I have received feedback to change the implementation, however this would require direct...
I have a streaming application (written over spark/storm/whatever does not matter). Kafka is used as a source of stream events. Now there are some events that take significantly larger resource (time, cpu etc) compared to other events. There are application specific nuances in how these larger messages are dealt with i...
I have started a flutter app and want to apply clean architecture to it. The first use case i have is the following: A user provides file(s)via "open file" dialogue. The provided files should be analyzed in first step. After this, a summary with different statistics should be displayed. For example how many files were...
I'm writing an internet service in Rust that works more or less like an HTTP-server, just without the HTTP part, and strictly over UDP. I also have a requirement to build it like an old-school game of the 90s, because it supposedly produces code that is simpler to compose, maintain and debug than any other way. So I ne...
I am making a web application for parameterized procedural world generation. Given the computational resources involved, this application involves a server backend for generating the world with an API connecting the server and client. This API is written in Python. To expand the creative possibilities, I would like all...
I have an application service that retrieves Order data. The service is consumed in UI, where it can be edited by users. Additionally, the users wants to see related data such as ordered products' descriptions. Is it UI's responsibility to load the additional data or should I modify the application service to include a...
I'm currently in the process of integrating Clean Architecture into my Spring Boot project and I'm seeking advice on the ideal project structure and the types of classes and projects that should be incorporated. Specifically, I'm looking for insights into how to layout the project and the essential classes and projects...
I've created a small prototype browser plugin and am now thinking about making it accessible to the public. This brings up an important question about gatekeeping API access and the right way to deploy a potentially expensive service. The plugin uses Firebase for user authentication and a database. It also needs access...
I am trying to apply DDD to a Vue project (so it's DDD on the frontend) and I have a doubt as to where store a props type. A Vue component can have props, which is basically named data passed to the component. Most of my components that work as a page are stored inside the application folder, because they manage all th...
I'm fairly new at system architecting and I'm looking for some advice. My company is revamping its order management system. Currently is a monolith system that scales very poorly and is difficult for various teams to work on at the same time. I am reworking this to be a microservice architecture. My initial team will b...
My team has a mixture of specialties, there's some overlap however. When some commits are done from person A (who is expert in some domain) and person B (who is not expert in that domain) I wonder if it is appropriate to ask in depth questions about the code or is not a good practice or to what extent we should allow t...
After reading What differentiates function objects from poltergeists?, according to the definition of poltergeist, I still don't understand why would "poltergeist" be a bad pattern: A poltergeist is a short-lived object, typically stateless, which is used solely to trigger or initialize several other objects and then ...
There is a variable that must persist between calls but otherwise only one method uses it. As it is a method of the object, the value can be persisted as a private field of the object, or otherwise it can be persisted as a static variable within the method. The initial value is trivial and can be easily assigned in any...
At work, we have a Web application, which makes queries to databases, and I’m asked to determine if using Web APIs could be an added value. Personally, I’m not convinced it is. I know Web APIs are tailored to let different systems speak a “common language”, but having one to just access databases seems overkill to me. ...
I have a Svelte web app exclusively for internal use, so there is no main landing page or registration, as accounts need to be created by the admin. Since the main page has no function as an unauthenticated user, it will redirect to the login page. After a successful login, there is a JS redirect back to the home page,...
The below code sample given is for Salesforce but it is close to Java and you should be able to understand easily what I am trying to ask here. AccountController.getAccountsThatMeetSpecificCrtieria is a method invoked by front end(ex: jsp) and if this method runs into any error, Salesforce says, we have to throw specif...
Hi I have following structure : Client App (layer 1) Business logic Services ( Layer 2) Business Logic layer consists of many microservices . Access token can be created and passed from APP layer to business logic layer. Business logic layer could validate the access token and allow access to required operations. But S...
I am currently struggling with how to solve nested grouping of data. The initial structure is given and my grouped structure below as well as my approach can be adjusted. My idea was to have the array of objects grouped by multiple parameters in a nested way. Let me show an example structure: - City: Zurich -- Date: 20...
I'm currently learning how to separate frontend server and backend server. However, i'm not sure which approach should i take between the two Frontend server obtain data from backend server and adjust pages based on result In this approach, user connect to frontend server, then frontend server connect with backend se...
The problem Let's assume such scenario: List of IoT devices (one model?) Each list item has (among other fields) a type field Depending on the value in the type field, device may report different values (by number and sometimes type) And I need to save them in the database (related to reporting device, of course). So...
I have a single connection being used by multiple devices, and I'd like to filter the messages so that each device only reacts to messages intended for it. This can be done with an unique ID field in the messages. I have two options. Option #1: Have each object filter the data from the connection themselves: class MyDe...
Let's say, in a rather big application suite with multiple more or less integrated products, data is stored across multiple databases. Some of them are SQL-ish DB clusters, some are MongoDB clusters. Some entities (= "rows" or "documents", depending on the type of DB) are stored in several databases. Many (if not all) ...
Some years ago, every API I developed was a REST API and I did everything to follow the best practices to make them "RESTful". But after some time, I have my doubts if RESTful APIs that should represent a Domain are not even an anti pattern. The most important reasons: The HTTP Methods like POST, PUT, DELETE and GET a...
I know there are some posts talk about primitive obsession : When is primitive obsession not a code smell?, Is "avoid the yo-yo problem" a valid reason to allow the "primitive obsession"?, but the posts mostly talk about business data fields like "ZipCode" and "Address" (I can't define what "business object" is accurat...
I made a small utility as a PowerShell script. It worked fine, but wasn't very practical when getting other people to run it who weren't familiar with PowerShell. I modified it to add a GUI using System.Windows.Forms and then used PS2EXE to turn it into an executable. Again, this worked fine - double click the exe, do ...
I have an end point where a user can start an update operation. I don't want to make the user wait for the result. There are two possible outcomes: The action is succesful - nothing to do for the user. There is an exception - this is logged (every exception is) in WatchDog and the database admin checks this. [HttpPat...
I'm modeling a part of Python/Qt GUI code which uses reflection to construct a collection of widgets, in a form. The code works like this: There is a Model which has attributes of various types, including (but not limited to) Foo and Bar. These types have corresponding widget types to be used in the form (FooWidget, B...
During my career I only used DI to insert object of certain class based on certain interface. So there was never the situation when I needed two different bindings for one interface. So natural question arises: can't I just use Concrete Factory instance of which I will create on compile time/runtime and use all over my...
I heard that if you maintain a program, you have to study what the code does. Another engineer said it is not necessary. Just use test cases to find out the function that does not work well, modify the code so it handles the new case, as well as the previous ones, and release it. So when fixing bugs, do you have to foc...
While writing the constructor for class A in Python, I calculate some of the class's fields using function fun(). This function is never used outside the constructor of instances of this class. In situations like these, I tend to write fun() so that it returns the desired values and then I assign these values in the in...
I am working at a digital banking company i.e company that provides software for banks so that the customers of that bank can use banking services via smartphone. But the documentation there is non-existent. I am always confused about the working of the various types of payments like: How does transfer of fund between...
On day 1, one person discovers a secret. You are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days after dis...
Working on DDD lately got me thinking about how it preforms on large scale systems. Watching many tutorials and reading many articles makes it look fun and promising for small projects. I have three questions for three different categories of DDD. Lets take the famous example of eCommerce, Say Amazon. Data Duplication ...
As I was reading this blog post: https://go.dev/blog/loopvar-preview about scope of loop variables and as I’m trying to learn #GoLang, I asked myself the question: “okay, but is really so common pitfall in practice?” Then I tried it with Subtest and Table testing, ...to me becomes blatant potential pitfall: func TestHa...
I have a question about what's the best approach to handle persistent data for web apps. I have a web app that is authenticating through an auth service. once authenticated it makes requests to the resource server. However, when a user logs in, they want the display settings of the web app to be consistent regardless o...
I have Firebase connected to my web app and users can authenticate using the 'microsoft' provider. The provider only allows authenticating with the active directory tenant that I specified in my firebase project. I also have a SQL database that I want to let the users connect to after they're logged in on my web app. I...
I'm in a pickle following a recent executive decision by our parent company. They have elected to abstract away our SQL data warehouse, transitioning to a REST API for data retrieval. The purported aim is to streamline data access, though, as anyone previously accessing the data warehouse will now have to make web requ...
Versions are on the form: x.y.z.[..] Where these letters are numbers and there are arbitrarily many of them. The first version is 1. The next one is 2. The only time when you branch out to the next components is when you have the following case: You need to make a new version on top of X X+1 is already released Then...
I would like to use std::chrono::time_point in some simulation software I am writing. I would like to take advantage of features like the time point arithmetic functions. However, I run into a snag. I need to define a clock to use with my time points, and the spec indicates that clocks have a now function such that ...
Are there any algorithms that can do or suggest merges without requiring the "base" file, the most recent common ancestor of the two file versions that we want to merge? Is a manual merge between two files still considered a 'merge'.
I believe this forum is the correct one for my question, based on the community guidelines but let me know if not. It seemed like the best fit. I am performing a data modeling exercise to formulate a conceptual model of our business to support our requirements. An obvious step is discovering the entities. My challenge ...
I need to process a queue of videos in a scalable way. Processing includes number of tasks that can depend on each other. Some tasks are computationally expensive some not (e.g. transcribe audio, clean up, summarize, extract features from transcription, etc.). I think to create a DAG to define tasks dependencies and th...
I have about 60 repos containing Python packages, currently using setuptools in a setup.py (run via pip install) to manage third-party dependencies. Most of these packages need to be installed on a system at the same time, which means their dependencies all need to be compatible with eachother. The dependency versions ...
I have a little pet compiler project that generates bytecode interpreted by a virtual machine. The language is kind of low-level, as it allows the user to manually allocate memory and dereference any pointer as they see fit. This can of course lead to bugs which crash the interpreted program. When the VM runtime is use...
Is there a reason to encode options like this: { "options":[ { "name":"opt1", "value":"val1", }, { "name":"opt2", "value":"val2", }, { "name":"opt3", "value":"val3", } ] } instead of like thi...
I'm working in a codebase at work that requires that anyone who wants to merge a PR rebase against the last master prior to merging the pull request. To further complicate things, CI (which takes hours) has to pass before the PR can be merged, so if someone merges a commit to master while CI is running, you have to reb...
Edit: I'm copying the question but changing the example code. Apparently, I used a bad example earlier that contained an imprue getter. I'm keeping the old example code at the bottom so the first answers stay relevant. Is storing computed values in the app runtime state always bad in OOP? Assuming that: Computation co...
I've just accidentally came across this answer about inlined functions and I'd like to know how this affects call stack. But I can't add comments because I don't have enough rep so I decided to ask this question. Also recently I discovered Tail Call Optimization (TCO) and now I want to learn more about this topic. And ...
I'm learning about graph algorithms, so to learn them better I'm beginning to write some of them using c++. For example, I created the code for implementing the Depth First Search algorithm. Here's the class structure I have: template<class T> class Graph { public: struct Edge { T src, dest; }; ...
Background Sometimes also referred to as doubly connected edge list, the HalfEdge data structure allows programmers to efficiently and easily modify topological and geometric properties of a mesh. Examples of things you can do with them in very efficient terms: Find all neighbours of a vertex. Split an edge. Split a f...
According to Explanation on how "Tell, Don't Ask" is considered good OO, I know I should avoid get the state of an object and then decides the actions to take to that object, eg: Bad: public class Manager{ public void scheduleCallback(){ if(this.systemMonitor.temperature>100){ this.systemMonitor...
This article on Medium addresses the scopes of the domain model in hexagonal architecture. I have sketched the following generic hexagonal architecture: On the one hand, the secondary/output adapter receives the domain model ("model" for short) and maps it to a DAO for persistence. On the other hand, the primary/input...
Consider I have 4 Services . Account Order Items Customer Now a External Partner Service calls all these services , by passing an External customer id ( EXT_CUST_ID) in the request. Our platform has a Internal customer id (INT_CUST_ID) which can be found by querying EXT_CUST_ID inside EXT_ID_MAPPING table . As EXT_ID...