instruction
stringlengths
34
36.1k
While practicing System Design, I decided to create a hypothetical proximity service (like Google Maps) with a microservice architecture. Suppose we have 3 core categories of functionality: CRUD operations for new Businesses (Stores, Restaurants, etc.) CRUD operations for users Search for and retrieve a list of Busine...
Please consider the following sample #include <cstdio> #include <functional> #include <memory> #include <utility> class PaintDelegate { public: virtual ~PaintDelegate() = default; virtual void draw(){} }; class PaintDelegateActions { public: PaintDelegateActions(std::function<void()>&&...
We have an object Root, which references many other objects. Which eventually is translated into FKs on the DB level. We came up with an ACL scheme where there's a separate permissions table with the user,resource,access_level. And so we change our logic to look at this table before returning the data to the user. Prob...
Java never had immutable primitive arrays. However Java does have an immutable List or Map or other collection classes and of course final primitive fields and variables. In Java if you try to make an Object or array final you only make the reference final. The reference will only point to the same actual object but th...
I wondered if it's possible to reverse engineer a Botnet "Node" (aka the Client/Malware), to find hard-coded values, like the IP of the Command Server (CnC Server) to catch the Operator of the Botnet? Like if there's some variable let server = "some_ip_goes_here" and it was compiled to an .EXE and you "de-compile" it?
This is a clarification of a closed question. I've limited the scope as requested. First, a few definitions, following e.g. A modular module system. Consider any programming language with a selected subtheory of its native type theory. Let a signature be two collections of named types, allowing for polymorphism; the fi...
I am trying to wrap my head around what the ECMAScript specification suggests about variable assignment. Introduction: Coming from Java, this is pretty straight forward. Variables get stored at a memory location and assigning one variable to another one copies the value of the first into the memory location of the seco...
I am coming into a project that uses an Amazon S3 Bucket for a process. For my application, I need to know (within a reasonable time - order of a few minutes, at most) whether a new file has beeen added to the bucket, and then download that file. Currently, an SQS queue already serves this purpose for another applicati...
Let's say I am writing a python module module.py. Which provides functionalities for other parts of my code. Of course, the module has to import other modules. A simple example: import abc as _abc import typing as _typing class BaseFunctionality(_abc.ABC): def get_sequence(self) -> _typing.Sequence[float]: ...
I created an abstract class to represent a vertex in a tree structure. Later, a requirement was introduced where certain types of vertices are not allowed as descendants of certain other vertices. So I updated the class. Here is something like what it looks like: <?php abstract class AbstractVertex { protected arr...
I'm creating a web app and looking to have a feature to show a history of updates/activities of other users to the current user. For example if another user creates a project. The user should see something like: "User A created Project 1 - Date, Time" Another example of such feature in Postman: How can I implement thi...
I am talking about these two testing strategies : Have a pyramid of tests (with many more unit tests than high-level tests), because high level tests are harder to maintain and slower (see also : https://blog.octo.com/the-test-pyramid-in-practice-1-5/) vs Test behaviors (high level tests), not implementation details...
There are several questions related to presence field tracking of scalar fields in protobuf 3, but I didn't find any with generic default approach recommendation. It may be useful to be able to track field presence in protobuf message. I see at least those cases, where it may be useful: API usage simplicity. In this c...
I'm confused about the meaning of API, specially in the context of REST. I'm thinking of one example. My company creates an application that runs on a server (the "backend"). (JavaScript in Node.js) To use it, my company also creates a user interface that runs on the browser of the client's computer (the "frontend").(R...
Let's say we want to return a paginated list of document id that a user can view. In DB, we have: doc_id user_id ABC user_1 def user_1 ... ... We use an external authorization service, so we can query if the user has view permission on specific doc_id, by using doc_id and user_id <doc_id>::<user_id>::vi...
I have a large (>1,000 LOC) Python ETL script - call it fetch_and_transform_data.py - that fetches data from a remote database, appends the raw data to a local table, does some transformations and appends the transformed data to another local table. Currently the fetch_and_transform_data module has a class with a main ...
Sometimes we have to use multiple databases in one project with the intentions of: Denormalizing data or read models Using the advantages of that database (technology) There has been a lot of talk about the 1st case, but I haven't found anything about the 2nd case Example 1: To solve the complexities of access in a...
CreateCustomer is clearly a mutation. GetCustomer is clearly a query. But what would be some CalculateProductPriceForThisAmazingCustomer? Is it a query, because no price is stored (no data written), it is just calculated? Or is it a mutation, because price was not stored anywhere previously, we are "creating" it in mem...
I have application X that can create "topics" where users can do operations, I want each "topic" to be a new "queue", so every "topic" operations are independent from another. I can create new queue on the moment of "topic" creation from this application. What is the optimal solution for the receiving application Y - i...
About tests: I have the following view on nomenclature: Unit tests are the kind of testes where you have a function ExtractBacon, where there is a function with an entry parameter Pig and a return of type Bacon. What you test, is for the Pig with A, you expect a Bacon with feature X=1 and Y=2. And you assert that what...
An application has a multifactor login. The user logs in with its e-mail and password, and then the following screen asks for a one time password received via e-mail or generated by a mobile app. In that second screen there's also a link called "cancel login" that points to, for example /login/cancel. The user can clic...
In my company, we are would like to recommend OpenAPI and using the design first approach to API development. We would also like to use the OpenAPI Generator to generated server stubs and DTOs from OpenAPI specs. We are using the OpenAPI Generator maven plugin as our projects are Java based. It seems though that the au...
I have a web service. When a user makes a request, traefik first redirects it to my users micro service, to pass through an authentication function. The token (or username+password, on first request) is checked against my users database. If found, the authentication sets the context and passes on the request. If not fo...
I've seen a ton of examples of how to do DI, and the example always shows two dependencies. But what about when you have 50 or 100 dependencies (or more) in a large-ish application? The Program.cs file will get unwieldy with 100+ lines of builder.Services.AddScoped<IDependency1, Dependency1>();, not to mention problems...
NOTE: Please don't respond by telling me that I probably don't understand what I am looking at. You can't possibly know that and it's wrong. Just don't answer if that's all you have to say. I'm looking for a term akin to the "N+1 problem" but for a different issue. I know that the term 'anti-pattern' may raise some h...
Sometimes, I have a hard time deciding between two good code traits: debuggability and readability. The snippets below are an oversimplification, but they illustrate my pain. Example 1: if(isSomethingThere(somethingParam) || isTheOtherThingThere(otherParam) || isWhatever(whatever)) { // some logic } Example 2: b...
We build up a microservice architecture which is called from above by a REACT SPA. All is deployed in the AWS Cloud, that is to say in an AWS EKS (K8S). We have at most 600 users in parallel. Do you see an urgency to apply primarily a sync over async (via messaging) communication in such a high performant K8S environme...
In the picture below there are some regions which are very bright (i.e. more white). Some bright regions are wide and some are narrow or thin. The red box covers one such wide bright spot, and blue box covers one thin bright spot. Thin bright spots are called edges and wide bright spots are called hot-spots. I want to ...
I'm facing a problem with handling different timezones in MySQL. I have looked into similar questions that were previously raised, but I couldn't find a proper answer. The issue I'm encountering is as follows: I have multiple microservices and a MySQL server. For instance, my mobile application runs in the timezone "+0...
Context: I am building a site that is essentially just a UI for eBird's API. My first question is about naming. Wikipedia defines a client as "a piece of computer hardware or software that accesses a service made available by a server as part of the client–server model of computer networks." So by this definition, my s...
I have many abstract classes that describe many abstract ideas and objects. These classes have many complex relationships with each other, and I realize that while writing code with some of the derived classes can get confusing. For example, it isn't completely clear at first glance if class C is derived from class A, ...
I have some classes like so class User{ Preferences List<Participants> BlueFontParticipants PropertyThatComputesFromAListOfParticipants<Participants> } class Preferences{ PrefersBlueFont //really only applicable if you have a bluefontparticipant PlayAudioAutomatically //only applicable if you h...
I have a Delphi software application that uses non standard port nnnnn to nnnnn+50 with the FTPS protocol TLS 1.3 Until now I was suggesting my customers that the Server Side application needs to have Public Static IP Physical Firewall Port Forwarding No sharing of any Drives/Folders Machine to be used exclusively for...
I've just started learning to use this architecture and I'm trying to build a simple project management app. The App works such that a user after registering, creates a workspace. This Workspace is made to contain the administrator (The user who creates the workspace) and other users he invites via email. Every user is...
I asked this questions on StackOverflow but it's definitely a bit too broad. Even for this website, although the question is about software design, it might not be enough "focused". I am working on a family of java 8 applications where a bit of refactoring is definitely overdue. Right now I'm focusing on the error hand...
Most of the articles I read state that the average number of defects per KLOC is 10-15 (most of the data seems to come from Microsoft). How does that number correlate with code coverage? If my project has for example 80% code coverage would that translate into 5x less defects per KLOC ? If not, how would I focus testin...
Originally posted here, moved to code review, redirected from code review back here as there is no code to review. I think the question is enough abstract to be asked here. I have a mono repo with multiple nano services integrated with Kafka. The system data vesel is JsonMessage. There Are multiple formats Of json mess...
My company* wants to move from using long-running feature branching (~up to a few weeks) to continuous integration with trunk-based development, and to break up our monolith into microservices. We're unsure which to do first to best achieve both: 1) moving to trunk-based continuous delivery, albeit dealing with a sev...
I need to build a data pipeline to populate a database from various files. This is a common scenario. However, I want to have expert opinions for implementing a pipeline that is robust, modular and resilient to future variations. There are several clients Each client shares daily data in different formats: Excel work...
We have a microservices application and our User management service is the source of truth for user's first and last name. But we also need these in the Reporting service, where we generate reports for the users that should contain their first/last name. Our Billing service also needs these names when sending claims to...
SQL-92 says: 16)For the <exact numeric type>s DECIMAL and NUMERIC: a) The maximum value of <precision> is implementation-defined. <precision> shall not be greater than this value. And yet it's 38 in Oracle, MS SQL Server, PostgreSQL, Snowflake, Teradata. Only MySQL and DB2 are diffe...
In most descriptions of unit testing as a methodology there's an idea of unit tests being as independent of implementation as possible. This is easy to understand and implement in cases when code does some actual computing, and may be represented as a math formula to certain degree. When input is correlated to output. ...
I will explain my problem in the form of an example. Suppose we want to use both databases in a transaction. Data is edited in database 1 (for example, Postgres) and then added to database 2. Finally, we want to commit the changes (uow.commit()). It is possible that the first database is committed and a problem occurs ...
We are beginning to add third-party integrations that all have to do with a certain business concept. (If it helps to make things concrete, in our case it's "measurements," i.e. third-party partners that track whether customers have visited websites, downloaded apps, etc.) Tech-wise, each of the third-party integration...
I have a large C++ project I'm hoping to release publicly soon (it is currently an internal development at work). We have a large auto documentation setup which uses doxygen and sphinx, however our documentation includes many images (useful as our tool deals primarily with image processing, geometries, and rendering). ...
Background Information We have a .Net core application that uses Hangfire (pretty version of cron) jobs to batch process different types of data. As a bogus example, we have one job that will run every 30 minutes to query an external source to get a list of products and saves them into a local database. (for discussio...
I'm currently trying to build a very simple application for handling OpenID Connect using the library Openiddict. This library lets me construct the access_token and the id_token and lets me set which claims/attributes to include in which token. And this is the part that I cant quite wrap my head around. Which type of ...
There are many packages for creating bindings of a library that's written in one language to be called from another language. Some programming languages also include such interop in the standard library, e.g. Julia can call C++ code without having to write manual bindings for it. With more languages becoming interopera...
I am writing a Windows Service using the Windows Background Worker Service template. Some data that I track needs to persist between application instances (i.e. after shutdown and restart). Initially, I saved this data into the app.config.json file. However, this involved clobbering the file. Normally, this wouldn't be...
Given a state machine that implements a certain protocol. I need multiple instances of this protocol running, so I create multiple instances of this state machine. Each instance is associated with a certain key. The state machine itself doesn't need to know the value of this key in order to do its work (state evaluatio...
What is the recommended approach for managing platform components within our internal JFrog Artifactory? I am currently facing difficulties in defining the appropriate structure. As an example, we are downloading the open-source Apache NiFi image and storing it locally in our Artifactory using the following URL: https:...
I was reading the excellent book by Axel Raushmayer, Tackling TypeScript. In this section of Chapter 7, the author makes the interesting claim In many programming languages, null is part of all object types. For example, whenever the type of a variable is String in Java, we can set it to null and Java won’t complain. ...
I have a state machine that, as a side effect of going into a certain state, sends a message to a remote server. In some situations, however, I don't want the state machine to send that message, even if it ends up in that specific state. The state machine itself doesn't know when such a situation occurs because that de...
I'm working on an app I created for myself using the MVVM architecture. On my ViewModel I have a list_items that, when changed, updates the corresponding UI element on the View. The list of items depends on the state of other UI elements. Right now I have this method on the Model: get_list_items(arg1, arg2, arg3) Wher...
I've recently joined a new company and they've been experiencing some issues related to their branching strategy which causes untested code to be released inadvertently. We have three branches of interest: main: this is the branch we release from develop: this is the branch that contains code that is yet to be tested ...
I am writing integration tests via unit tests by using Xunit. (the specific testing framework is not set in stone, Xunit is being used simply because it has been used before in this project team) The integration tests will test the workings of an API that facilitates certain operations on AD accounts. We will be given ...
this is my code: System.out.println("--------------------------"); if (person instanceof Student) { Student studentPerson = (Student) person; System.out.println("GPA: " + studentPerson.getGpa()); System.out.println("Major: " + studentPerson.getMajor()); System.out.println("Year of Graduation: " + studen...
I’m evaluating different options for communication between C# applications. My requirements are: Central server where clients connect Persistent connection, server should know when clients connect/disconnect. Server can broadcast messages to all clients Server can send messages to individual clients Clients can send m...
I got a few questions about using UML state machines in software architecture: I have to design an STM and express it as part of a UML model. There is a singelton STM Maintainer holding the instance of the STM and performing state transitions. There is also an STM User class, reading the value - the currently active s...
From my conversation with @Steve in the question Is there any philosophical theory behind the concept of object in computer science? on Philosophy Stack Exchange: Steve: More often than not, programmers haven't in fact been equipped to understand how things work in the real world - not even their own computers, let al...
Event-sourcing often implies to have one row per aggregate id : event_id event_type entity_type entity_id event_data 102 OrderCreated Order 101 {...} 103 OrderUpdated Order 101 {...} This is perfectly fine, since it allows for an aggregate to be rebuilt by applying all events for a specific entity_id But ...
I have a class that has dependencies that I know are not going to change. class ConversationFinder { public function __construct( protected Conversation $conversationDbFinder = new Conversation, protected ConversationMessages $conversationMessagesDbFinder = new ConversationMessages, prote...
I feel something is wrong with my approach handling MVP and the Repository Pattern. I'm making an album winform app just to practice MVP, crud and the Repos. Pattern. First some code. The model: using System.ComponentModel.DataAnnotations; namespace Models { public class Album : IAlbum { [Key] ...
I have some incoming request - it's an instance of class generated from api specification - POJO with public getters/setters. I would like to normalize some values. For example dimensions (to use metric system). I have a service class which has method processing incoming requests. First I would like to normalize the re...
I (unfortunately) work in a large German corporation, in a department where the codebase is up to 20 years old, written in C++ (actually more like C with the occasional classes, since most developers used to be electrical engineers). We have a requirement to adhere to certain security standards (which ones exactly I am...
This well-known article criticises Java on the basis that it does not allow you to write functions that do not live in a class. This flaw forces you to write classes with names that look suspiciously like verbs, such as GridCellHander or GarbageDisposalDestinationLocator. In other words, it looks like you've built a cl...
I have a form. It contains things like grids. Users do things with these grids and what they do with them is sent to a SQL server. Clearly, the server is a volatile dependency and should be dependency injected. Of course, it would be silly to have the form know about my business logic, so all of the business logic to d...
In my little WinForm app, intended to practice as a hobbyist, I'm using this code to pass data from the View to its Presenter: public event Action<object, string, string?>? SearchInAlbums; private void Btn_SearchInAlbums_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(cmbSearc...
I noticed a huge portion of software apps only support Windows and not Mac or Linux. I understand that there might be an API that they're using that only exists on a certain system. In this case, why don't programmers use cross-platform APIs instead, that have portable frontends that interact with non-portable backends...
In C, such as in many POSIX structures, the structure members are prefixed with an abbreviated version of the structure such as: struct passwd { char *pw_name; char *pw_passwd; uid_t pw_uid; gid_t pw_gid; time_t pw_change; char *pw_class; char *pw_gecos; char *pw_dir; char *pw_shell;...
I'm and entry-level developer straight out of college. I am the only developer at this company. I feel the challenges I face are different to most people working with sub optimal or very poorly written code, because I am not only not part of a team, but also entry-level, and have no documentation, or tests. I've been t...
There is a string field x, contains value a/b/c/d The order of a/b/c/d is changed infrequently , only once a year or several years. What is the best approach to store this config? Currently , it's being put in config file and there is discrepancy between prod config file and source control. edit 1 : I didn't share my t...
It has caught my attention that both arguments of fopen are both restrict-qualified. It's been that way since C99. What does this achieve? If I have: const char *path = "foobar"; const char *mode = path + 5; FILE *f = fopen(path, mode); is the behavior undefined, since the mode pointer accesses something which is als...
Aside from modes, Antlr grammars can use "actions" which have to be written in the target language, sometimes seen used to conditionally push and pop from the mode stack. If I were to make a parser generator, how should the lexer be stateful? Specifically, if I want to accommodate all mutations that rightfully belong i...
I've been a software developer for 20+ years, although it's been an unusual career. I've mostly worked on either legacy projects, or small standalone, non-public-facing apps and so only a couple of times has it been mandated by my employer to include unit tests in my work. To be honest, I struggle with the whole conce...
I have a class file Settings.php that loads an ini file and assigns the content to a constant for global access and reducing clutter. The class file contains the logic for loading the settings and define the constant (sorry for the large sample didn't see a way to compress this: <?php declare(strict_types=1); namespace...
Say you want to test an update capability across a CRUD api. Test A updates a field, queries it, and asserts that it now has the value from the update. Knowledge about the starting value (and that it differs from the test value) comes from the way the initial data for the field is prepared: it is done by an utility com...
Two recent failed projects in my career involved trying to implement a discount/promotional offer system for retail. For example, a retailer may want to offer discount codes in emails or newsletters, or offer special incentives to order on a holiday. Each use-case seems simple enough to implement. For discount codes, f...
Edit based on responses so far I am starting with an edit so as to save future contributors from going down the same path others have. I am only interested in contributions that stick to the exact definition of SRP I have quoted below. So no “you can think of SRP as…” type elaborations, as that takes away from the obj...
I'm wondering how i can implement what Im calling "business policies" in my code? For discussion purposes, let's say I have two separate contexts - synchronizeUsers and Licensing. The synchronize users bounded context is a downstream component that connects to a Open Host Service, gets a list of changes to users, persi...
How should I design a relational schema to store graph documents that can contain plain nodes (shapes, in the example below) as well as nodes that can reference other graph documents? To visually describe the data I'm storing, consider document A with three nodes, two of which are shapes and one is a reference to docum...
The context, or bounded contexts, it could be defined as a logical boundary of a domain where particular terms and rules apply consistently. There are another definitions but more or less, this could be a star point. According to that. Supose that I want to manage the order of the clients. In this case I would have a b...
I was looking through the prettier docs and the prettier source code. It essentially has those defined helper functions to layout the text, given an AST. It operates on the level of the whole file, on many elements next to each other. It takes the AST and outputs text, not outputting a modified AST (like ESLint does). ...
I have an app that has an assets table like the following: user_id code current_price 1 ALUP11 12.5 2 ALUP11 11.9 user_id and code are unique together and current_price is updated if the user triggers a task that fetches the values from another service. I'm also using CQRS so when this task finishes it up...
Domain Object, while not necessarily a design pattern, can at least be considered as a design "concept", and one of its points is: https://wiki.c2.com/?DomainObject Domain objects should not direct their persistance. They don't know how to be persisted and even if they will be persisted. The infrastructure layer is th...
In C and C++ we need to declare a function before its usage, if its definition comes after where it is called. (Well, there is also the "implicit declaration" rule in C, but it is rarely used.) However, in more "modern" languages functions defined later in the same module are implicitly "declared" (or has the same effe...
I have some doubts about the state pattern, but I think it is better to ask one question at a time, so it is easier to focus on the answer. The state pattern establishes which actions can be performed according to the state. So, if the context is in state A, I can perform actions 1, 2, and 3, for example. However, my d...
I want to allow some Java objects to be translated into a string representation which matches Python or JavaScript objects. I thought that I could tag all compatible classes with compatibilising interfaces: public interface Pythonable { public String toPython(); } public interface JavaScriptable { public Strin...
I have a project with various bounded contexts. I have Purchases bounded context and product bounded context. The two projects are developed by two diferent persons, so I am organazing the projects in this way: MyProject.Products.Domain MyProject.Products.Repository MyProject.Products.Comun MyProject.Products.Appli...
This is something that I come across fairly often, and there are a couple ways to proceed, but never know which is the best way. I usually pick one way at random. I'm looking for a framework that I can apply each time I am faced with this problem. The problem is this: I am working on a bug. In this case, the bug is due...
When creating the crud GET methods to get a list of items, or the details, what should I return? The whole object properties for both cases? Or just the properties that are necessary? I'm asking this because it may be related to a future api that I call to change some of the products status. For example, imagine the fo...
I have a Java Spring boot microservice in production which supports multi-tenancy and the tenants are isolated at database level. This microservice exposes REST APIs for communication. During a request, the tenant ID is passed as a header which is read by the filter and is put in ThreadLocal as a Tenant Context. One of...
I'm currently working on a Turborepo project (monorepo architecture) and I have managed t share my locales files to both back-end and front-end parts. This means I share the exact same keys across those 2. When coming to internationalization, I've asked myself few questions and came to these conclusions: Server sendin...
I have 3 classes class Backup end class Database end Class App end The backup database has a reference to Database and App, like class Backup def getDatabase Database.create end def getApp App.create end end Similarly Database has a reference to App. Practically, If I am creating a backup object, i...
I have two npm packages that build on top of our core software platform. Their core functionality is mostly different, except for how they serialize data. This is and will predictably stay identical for as long as these systems operate. The code for serializing said data is very short (~200ish LOC), so the dilemma I'm ...
I am using the c language. I created one lifeline for each file. I am confused about the activation box. Many people said an activation box indicates an object is active and processing a task. In case of c language, can I say an activation box indicates a function is running? For the example below, is my UML sequence d...
Let's say that I have a Parent class and a Child class, Parent relies on Child to perform, say, some network request: class Parent { ... public init(){ const child = new Child(); const stuff = child.fetchStuff() } } class Child { public fetchStuff(){ const stuff = fetch("blah blah"); return ...
I need to be able to track users' time spent on the app and on each page (based on URL). I have a visits table that logs the users' page visits (by URL) and time spent. The time spent is done using JavaScript that tracks activity on the page. The DB table has the following structure: id user_id page_url visit_start...
We are going to have multiple microservices and decided to use api gateway. What we couldn't decide is if we should go for a single gateway for all of them or one for each. The reason why one for each is considered is having all api routes for all services in a single gateway feels like it's creating more coupling betw...
For example, many dating apps are limited to only certain cities of the USA. Or, they launch first in only regions and then may be unlocked across the country. Why the restriction? Why wouldn't you want your app to be used by as many people as possible?