instruction
stringlengths
34
36.1k
I am reading the paper "Ethernet Goes Real-time: a Survey on Research and Technological Developments". In this paper, it says "Flow control can be implemented on a link-by-link or end-to-end basis" Link-to-link means flow control examines only an individual link between switches or stations. End-to-end means flow contr...
I've noticed this kind of architecture in hub payment systems(system where you can pay to multiple merchants at one place-thus called hub). payment app-->payment mediator-->bank server Bank server deducts money Bank server responds that it deducted money to payment mediator Now payment mediator requests for verificati...
I am planning to design a microservice system architecture for a ticketing platform. It will be similar to "TicketMaster". Here is the flow of my architecture: client web browser API gateway (nginx) Virtual waiting room (AWS Simple Queue Service) Once the user is out of the virtual waiting room (queue), an "identity" ...
I am hoping someone has had to do this before and can help. I have a multi tier MVC application that I need to add WebApi, in preparation for moving to .Net Core + react and a new set of controls for displaying data. App built on .net 4.7.2, SammyJS (SPA), knockout (will be switched to React in time), and MS SQL Server...
I have 5 interfaces in an API component, which in its turn call an external 3d party solution provider (REST). The goal is to make this component universal, and under the hood support multiple service providers from the same industry for example, loyalty management. In other words the API component is a facade / gatewa...
Given a class which has certain private, constants (e.g., configuration), should these (A) be included in the declaration of the class (in the private section) or (B) should it be "hidden" with the definition (in the source file). Option A //MyClass.hpp class MyClass { public: int foo(int a); private: static co...
In the solution I've been asked to maintain (Meteor based app), there are several responsive SVG charts. When the page is loaded, settings for each chart are stored using the following: <input type='text' id='chartA' style='display:none' value='{{settingsChartA}}'> Then, when the window is resized, there is no curre...
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type possible, but the question is about template class or containers, how about the non container class? For example, suppose I'm using a UI framework, cocos2d-x, which Label...
Here is a passage from the Blue book: Distributed system architectures, such as J2EE and CORBA, provide special publishing mechanisms for SERVICES , with conventions for their use, and they add distribution and access capabilities. But such frameworks are not always in use on a project, and even when they are, they are...
I'm using python and fastapi with oauth2 flow (just for clarification as the question isn't language specific). I'm confused on how to implement scopes in an efficient and secure way. I was thinking of using roles and associating scopes to these roles, so when an user with determined role logs in, the API issues a toke...
I'm designing class library with background service which has public static class ServiceCollectionExtensions Which have few methods which will be call outside. Now above mentioned extension will call Builder pattern which actually building a services/Adding the services. Now my problem is I'm designing a Mass-transit...
My code has 2 python methods defined, m1 and m2. m1 receives 6 arguments - p1,p2,p3...p6. It uses p1 in its own code, but passes p2-p6 to m2. Is there a recommended programming style here to prevent the definition of m1 from getting too verbose? Is this a good scenario to use **kwargs in?
I'm making code examples of how to start a modern microservices web architecture from scratch, and I only recently learned about API gateway pattern. So far, the authentication methods I used for microservices were either duplicated in every service or centralized via an internal auth service, called inside the other s...
I have two bounded contexts, one to handle files and another to handled bills. I have two projects, one for each bounded contexts. Files can be any kind of file, an image, a document in pdf or any other format and so on. I have a many-to-many relationship between files and bills, in the way that a bill can be related w...
I am trying to write a simulation that has multiple (20+) variables, which the user should be able to control without modifying the source code. Currently I'm stuck between two design choices: Should I use one big class or multiple smaller class? Should I use a map/dict, or a class? Example, class Car: class Engine: ...
In C# and C++, an apparent trend is in place to reduce / avoid inheritance: C#: "Sealing types can improve performance." https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1852 C++ "Prefer concrete types..." https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#SS-concrete I ...
In a spare-time project of mine, I implemented RSA public-key cryptosystem. Because the official PKCS#1 standard specify key formats in terms of ASN.1 syntax and DER/BER coding, which is a coding with variable-length encoding of lengths, I had to design a 2-pass interface to accommodate its encoding, where in the 1st ...
I am working on a Go application where two concurrent maps, products and productCatalog, are accessed by numerous threads in live traffic to retrieve data at high throughput. These maps are populated with data during server startup and are periodically updated with delta changes every 30 minutes from Kafka. products ...
In trying to learn DDD by applying it to a new project, I've run into an obstacle. Here's a simplified structure of my very real domain: a project has many components which have many objectives which have many contracts for carrying out said objectives. Project A |_Component A |_Component B |_Objective A |_Contra...
Let's say I have a blog, I use DDD approach, I need to pass an instance of PaginationParameters class to PostsRepository, is it ok to bind DI container to concrete instance of PaginationParameters with exact values (let's say page_number=1, page_size=10) passed from HTTP request?
I'm making an interpreter (currently in python but later I'll remake it in C++) and I wondered how I could use a C/C++ function in my language so when somebody wants to write an extension for my language ex. an OpenGL extension he can bind the functions to my language.
I am working on a simple client server program in C in which multiple clients will be connected to a single server. Clients will submit operations/actions to the server and the server will process these requests. These operations may be expensive and/or long running so ideally I would like to have a thread pool on the ...
First of all, let me clarify the terms in order to avoid any possible misunderstandings. Language is considered to be compiled when a program written in it's source code cannot be run directly without additional steps under normal conditions. That means it's usually and normally done that way. Technically we have onlin...
I get that IOC containers can be useful to help break dependencies and allow you to test a class in isolation. I don't wish to focus on that right now, instead, I'm trying to understand some of the other arguments for using an IOC container. There's quite a few articles out there that introduce IOC containers (and the ...
I have a server which maintains some shares state. The clients can send some requests and get an answer from the server. Sometimes the server needs to give some information to the client asynchronously (without getting a request first) To make it easier on myself I would create two TCP conntections. The first where the...
We have a .NET 6 application that consists of a REST API running in Azure App Service, and long-running background jobs hosted in Docker containers. These jobs are triggered by messages in a message queue that is fed by the REST API. Logs from the web app are written to Application Insights, which works well for that p...
I have a legacy 32-bit Win32 DLL driver that interfaces with a test equipment. I possess the API header file for this driver, and I dynamically load the DLL at runtime within my C++ test application using Visual Studio 2019. My goal is to port this test application to 64-bit architecture, but there is no corresponding ...
I’m trying to use a VPN on an unreliable network that blocks UDP and randomly kills TCP connections (by spoofing RST packets). With OpenVPN this is tough because all the tunnel traffic gets sent through a single TCP connection. When that connection gets killed, the client has to open a new connection and start a new se...
I have a package that provides an object with quite a lot of features owned by it. Let us say the object is an HTTPServer, and when the user initializes it by providing config and a request handler object, the server would be serving HTTP with added request observabilty, panic handling, and other in-house logics. Now, ...
I know there are some questions about "Introduce parameter object", eg: Is "Introduce Parameter Object" actually a good pattern?, Should we avoid custom objects as parameters?, which means this form: public void myMethod(int parameter1,int parameter2){ } should be refactored as: public class ObjectForMyMethod{ pub...
I have a Spring Boot application which is containerized. The application has become huge with lots of complications and its difficult to maintain it. So I am thinking of breaking it into microservices. I have gone through the theory for microservices and have a basic understanding about it. First things first... I have...
As far as I understand it, the URI specification says that URIs are strings of the format scheme:b, and the format of b is specified by scheme (and there is not a finite centralised list of what scheme nor thus the formats of b can be). So what's the point of that? Why would you want the concept of URI to exist? Why is...
I have a private S3 Bucket that contains a lot of folders (currently 1000 folders). The amount of folders changes (new ones are added, old ones deleted). Every customer has to register and log in to the application, which uses AWS Cognito, to access those folders over a fronted. A user can only access specific folders ...
I have a Java project where a coverage analysis tool is being used (SonarQube). It rightly declared that code similar to this was a potential performance issue (Encode.forJava would still be called if the log level was above INFO). public static String foo(String bar) { log.info(Encode.forJava(bar)) ... } The fix...
I would like to discuss with you this way about the best way to work with git. We are currently developing software with three people. For version management we use git. The main branch is our productive branch. In parallel, everyone works separately in his own feature branch. This branch is regularly pushed and may be...
I am developing a game idea that has a large collection of objects/widgets (let's say 5 billion objects). They each have specific attributes as follows: style (10 styles) pattern (4 patterns) color (10 colors) type (15 types) etc. etc. etc. (The number of attribute categories has not currently been determined). An e...
The Decorator pattern allows behaviour to be dynamically added to an existing object, effectively "decorating" it with new behaviour. While the pattern as formalised and named seems to have been popularised by the "Design Patterns" book in 1994 by the Gang of Four, I'm curious about its origins. In functional programmi...
I am working on a simple interface to SharePoint via Graph API. I have created a project that references Azure.Core, Azure.Identity, Microsoft.Graph, and other dependencies required to make calls via Microsoft's Graph API. This project is our API project and other projects will reference this API project to be able to ...
Typically, when writing unit tests I tend to need to stub out collaborators and also mock some behavior in one or more of the collaborating objects. Say if I am testing a Service that is using a Dao, I will need to inject a mocked dao in the constructor when setting up the test. But creating new classes at runtime usi...
In my projects I have several third-party Python packages which I need to build from source (because there are no .whl packages published for the versions+platforms I need). Currently these packages are built in the Dockerfiles which create my development containers and deployment containers. This has a few drawbacks: ...
I am trying to write a unit test for a helper method in my ApiRequestHandler which handles APIGatewayProxyRequestEvent . This class uses an EFS file path, which is where it writes files to. I have this stored in my codebase in public final class Constants as public static final String EfsMountPath. Obviously, I cannot ...
I've been struggling with refactoring my code to use a generalized design pattern for a theme I see being repeated. The biggest struggle is that each instance of this repeated code uses different types. I have a tendency to keep code generic, but I haven't been able to find a way to support this with generics, even tho...
I'm working on a component that needs to draw chart-like structures like this: One issue I have is when multiple values are too close with each other. Here's an illustration: The last values for the blue, green, and purple charts are so close that one can barely decipher the 61.0 corresponding to the latest blue valu...
I am currently working on a codebase that is full of objects that are 3000+ lines long and have at least 20 dependencies each, and I'm about to try covering them with characterization tests before I start refactoring them, but I'm not sure how to deal with the dependencies they have. at first I thought "if I don't mock...
In the question What is "low code"?, there are many comments against it. One example: In my experience these tools are managed by business users until they've painted themselves into a corner. Then developers are brought in to untangle a gigantic mess of unreliable buggy garbage with gobs of unnecessary complexity. H...
I was reading Martin Fowlers take on Dependency Injection, and in general have been trying to discuss it a bit online to help get rid of my own misconceptions and to understand this principle better. In this article, he talks about one of the benefits of using dependency injection, which is that it allows you to share ...
Please advise me what pattern to use in following case: I have a Java/Spring Boot application. There is a component with @KafkaListener method which receives Kafka Messages on CRUD of various subject notifications, grouped in a bigger logical groups/types/topics (e.g. topic "humans" notify on "students", "teachers", to...
class ItemList { constructor() { this.list = [];//list holds many instances of Item Class } removeItem(id) { //...search for item in this.list, remove it } } class Item { constructor(parent) { this.id = 123456; this.parent = parent;//ItemList } removeSelf() { t...
What is considered better practice? Case 1: if n == 0: doThis() elif n < 0: doThat() elif n > 0: doSomethingElse() Case 2: if n == 0: doThis() elif n < 0: doThat() else: doSomethingElse() The first case is more explicit and (arguably) clearer. The second case doesn't handle the incorrect case ...
When using properties in a Python class, you have a lot of boilerplate code. Is there a best practice to hide the code for the getters and setters? I know about @dataclass, but the problem is mainly with classes that are not data classes, where you have to scroll through the boilerplate code to get to the actual functi...
Ive been tossing this around in my head for awhile. But I'm working on a project that consists of an Order, that has a OrderStatus. There is quite a bit of logic that revolves around the status and changing of it. I've got my fake order class below and I'm curious on the possible ways of implementing this logic - I've ...
According to Should interface names begin with an "I" prefix?, I should not add prefix "I" to interfaces. However, I think prefix "I" in interface may be useful sometimes. For example, if the interface have totally different names with the implementation naturally, eg: "Fruit", "Apple","Orange", then I agree it doesn't...
I'm building an application related to donation on streams. And I have such models as "alert" and "alert-template". "alert" is a set of different parameters to understand when alert about donation should be displayed. "alert-template" is a visual config for the "alert" (image, audio, positioning). At the end, on stream...
Currently, all REST applications I work with have a three-layered architecture: Persistence -> Contains "entity" classes with JPA annotations / Spring Data JPA repositories Core -> Contains "model" classes which are POJOs, along with "service" classes that perform business logic by using repositories from the persiste...
Suppose there is a C++ source code base of millions of lines composed of several hundred *.cpp and *.h files. There is also a driver program main.cpp that uses several header files from the above source code. Suppose I want to scan the entire code base and (1) pull only those files that are used by main.cpp, and (2) ke...
I know that it is common for software to have parallel development in major versions, such as v1 (1.x.x), which can be completely different from v2. Regarding Semver (Semantic Version), can I upgrade to a patch version (e.g., 1.0.1) right after launching a minor version (e.g., 1.1.0)? Let me describe a situation that I...
I have a program which needs some constant data, in JSON-like format. However, this data only needs to be consumed by my Python program, and by making it Python code, I can include types like datetime.datetime and enums, as well as custom types and any other type I wish to use. It would also improve performance, as par...
I'm try to improve our deliver time from start to end. I read google post about 4key metrics. I have questions that don't find answers in any post. 1- Lead time definition is "The amount of time it takes a commit to get into production". When do you push first commit ? For example I have task. I can do big part of task...
Currently we are moving to an API driven architecture using SPAs and WebAPIs. We are also moving from SAML2 to OAuth 2.0 and if it is appropriate, OIDC. We have a couple of APIs and one of the APIs can check if a user is under guardianship. This API is being called directly from the SPA and is used to detect which data...
I need to work out the architecture for a NASDAQ frontend charting application (a desktop app in .Net). Note that this is NOT for real-time quotes. NASDAQ provides an api that gives historical pricing, limited to one year's data, which is fine for our purposes. First I use that API to get the data (it comes in csv file...
The issue that I'm facing is on a banking app. There are two ways to register for internet banking. A) Self Register B) Ask for bank to register via their GUI panel backend. Consider this scenario: Say a customer is already registered MANUALLY (via bank). Then he requests to change his mobile number to something else...
Let's assume I have a batch job that needs to print orders. It will do so by getting orders from the order service and send them to the print service. It uses HATEOAS to discover the link from the root on the order service to get the orders that need to be printed: GET https://orderservice/ { _links: { ordersToP...
While sending FCMs, I've noticed these two headers are important(message won't go without these headers), but what could be the cons of sending both of these headers as it is? I tried to read about these content-negotiation headers but could not find any information about them in internet. The internet says that we nee...
According to Is this a violation of the Liskov Substitution Principle?, as I understand, the top answer currently says the code below is violating "Liskov Substitution Principle": public class Task{ private boolean isStarted; private boolean isClosed; public void close(){ isClosed=true; } } pub...
I'm working on an Excel tool that needs to synchronize with a CRM via its API. The CRM's API authentication process involves logging in with a username and password, after which a session key is provided for subsequent API calls. My primary concern is about securely handling this session key: Authentication: How can I ...
I have more than 10 years of experience as a web dev. Mostly do Front-End stuff, but I also do backend for personal projects. I never had this kind of bug in my app that required clearing the cookies to fix the issue. And this happens a lot with a commercial website that I use, if something doesn't work the support say...
Regarding my last question: Can 1.0.1 be launched right after 1.1.0?. I learned that releases can be maintained in parallel using SemVer and it is possible to apply it using Git Flow (Reference: Post of Vincent Driessen, https://nvie.com/posts/a-successful-git-branching-model/), of course, doing some adaptions to bette...
At first I had the following logic of user creation: class UserService { constructor(userRepository, postRepository) {} createUser({user}) { this.userRepository.create(user); } } Then I also got another use case when while creating a user we also have to create a default post for him. The new use case shoul...
I am working on a code library containing data structures and algorithms for solving parameter optimization problems. A parameter optimization problem is a problem of the form: given a vector of parameters P, and a loss function L(P), find the vector components of P such that L(P) is minimized. The implementation of th...
I am rewriting a streamlit app that is an interface to a laboratory management system (LMS). This means, that I have to make a lot of requests to that LMS through its python library (PyBIS). The way that library works is, that I import a class and instantiate it, and then call a method to login to the server. This logi...
As an embedded developer, I often write drivers for hardware (though this question really applies to any shared resource). The "standard" interface I have come up with looks like the following. As an example, I will showing an interface for a "Voltage Probe." class IVoltageProbe { public: virtual void enable() =...
I would like to have a series of small stand-alone services that would either consume a Kafka topic and output the data into a different system or the reverse: receive data from a system and produce Kafka messages. What would be the right approach for such applications? Example 1: Converting a SQL query result into a s...
I am looking for a complete pattern implementing cache-aside when used in a distributed system across multiple nodes read/writing from/to cache. Specificly how to avoid making multiple requests to db and multiple writes to cache of the same data when all nodes concurrently encounter a cache miss The problem described i...
I need to refactor a class that became too messy. The class has a method that reads some raw data from one of our repositories, and another that "filters" it: The data is in the form of level and on/off, for each X*Y of the units we have. The filtering process lets some of the data pass in the raw form, changes a small...
An asymptote in mathematics represents a value (line) to which the observed function constantly approaches. In other words, as the value of X increases towards infinity, i.e. decreases towards minus infinity, the value of the function approaches that value/line (asymptote). When we talk about the big O notation, such a...
I have to create a service/app which allows creation of custom report templates & schedules using those templates(like create the report daily) that will generate the report in a the specified format (CSV or PDF for now) and send it onto a fileserver through SFTP. The backend database is Oracle, rest of the stack is in...
I'm working on a small project and I'm randomly generating "world maps", with nodes you can fast travel to along given routes. The basics of this aren't complicated; throw random points on a 2D plane and run a Delaunay triangulation. However, this leads to quite densely connected maps; there are convenient routes liter...
I am new to Dart/Flutter and try to use the Bloc framework for my current project. I am now at the point, where the data, especially in states, is getting more complex. For example: A certain state holds a big list of items. The items itself holding other items which are holding certain properties etc. From other progr...
UPDATE: Myself and the business unit leader were able to make enough noise with the bosses such that the vendor has agreed to prepare User Stories for the work they have done and also for all new work going forward. The bosses did NOT seem to ever care about the whole "Agile" angle so it wasn't a selling point for them...
In my library I've got a Logger class that is a wrapper around spdlog, that I use internally for logging. Logging is enabled by default in Debug builds and disabled in Release builds, moreover user can force enable logging in Release builds via CMake option. Also logging level is spdlog::level::trace by default. There ...
I'm designing a database where a user can add notes on diffrent entity of the application. For example, the user can add a note on the project and/or on the project line. The note added can have different type, even if are on the same entity. For example, I add a note on project, I can mark it as "Customer follow-up". ...
TL;DR I want to change the way our current enterprise code base is constructed to utilize NuGet packages for the inter-project references, but that seems to present some challenges when considering how that affects the team development environment. Please see the various sections below in bold for the details. Forgive ...
There's a section about use of checked exceptions in Josh Bloch Effective Java and I find it a bit abstract to understand what he means by saying "when a user can recover from it". Authentication eg. can fail if credentials are wrong, but I wouldnt want to crash a client if a user provides wrong credentials. So is here...
In our company we have a monolith. Right now is not that big but we are already seeing some problems with the isolation between the modules we have. Our setup is pretty similar to other Django backends: we have a common User model and another UserProfile model where we store additional information about the user. As an...
In chapter 9 (Testing) of the book Building microservices (2nd edition) Author suggests using a Fan-in approach to have a single shared E2E tests for all microservices. This way tests of unchanged services doesn't have to run again and make the whole process faster. Question is, Lets assume "Web shop" service is runni...
If you have an OO language, where every object always has a copy method, shouldn't that be deep copy by default? In most languages I know, such a copy method is shallow, since a shallow copy is more lightweight, of course. It's faster, it requires less memory, and it's quite often sufficient. And when you ask for deep ...
Question Summary I am writing a program that will run on a Raspberry Pi 4b+ designed to manage hundreds of LEDs, as well as a few other devices (such as small motors). This is for a project I am a part of- a LEGO City designed to simply and accessibly demonstrate cybersecurity issues in a model city with the modern tre...
For example, for base and child classes, if all child class need a class member, eg: baseHp, which represents the base hp to calculate the actual hp of monsters in a game: public class Monster{ private int baseHp; private int lv; public int getHp(){ return this.lv*this.baseHp; } } public class ...
So this is a basic question that was asked by a junior developer (not in these exact words). He had worked on a feature which was used in multiple projects. The main feature can be easily isolated and written as a library and can be used in three projects. The feature was basically showing a regulatory dialog when the ...
I am writing a API endpoint in NodeJs, The code is roughly like this: function myApi(myUserId, userIdToDelete){ if ( checkIfIAmAdmin(myUserId) ) { deleteUser(userIdToDelete); } } Now, checkIfIAmAdmin() and deletUser() perform database operations, but as you can see, not atomically. This means that bet...
This is the situation that I've seen two times in a row already. A company makes software intended to be sold to other companies. So there will be relatively few clients, but each is an important one. An obvious, though by far not exhaustive example of such software is an ERP system. Now each client company has their o...
I am creating a C++ library (more of a passion project to be honest). Its aim is to enhance the existing unordered_map STL by giving it indexing abilities and range-based loops, based on the order of insertion. For example, if I have an unordered map with the following order of insertion: key1 -> val1 key2 -> val2 key3...
Suppose we are writing an interface class which has some "properties" and "operations." Assume also that every concrete implemented of the interface must contain the same set of properties. There are two ways (that I see) of expressing this interface in code: Option 1 class Interface { public: virtual void doSomet...
I want to create an endpoint for posting different types of commands. I have the option to have one route /commands which can be used for every command type or one route for each command i.e. /commands/commandA, /commands/commandB etc. Which one of these approaches is favourable or is it a "it depends" case? What are t...
I am trying to get a better understanding of TDD. From a quick google I've found this: In layman’s terms, Test Driven Development (TDD) is a software development practice that focuses on creating unit test cases before developing the actual code. It is an iterative approach combining programming, unit test creation, a...
I know there are some questions about boolean flags: Is it wrong to use a boolean parameter to determine behavior?, Multiple boolean arguments - why is it bad? which indicates the following code is bad: public void myMethod(boolean b){ doThis(); if(b){ doThat(); } } myMethod(true); and should be re...
I have a rabbit queue that I use to communicate between applications. I have a chain of three message. App 1 generate and push a message in rabbit(message 1) App 2 catch the message and generate another message(message 2) App 3 consume the message 2 and generate message 3 I have in each message Correlation Id, is un...
I have a specific domain entity that has a given type and some attributes. Based on the type, it can have another set of type-depending attributes. Normally, I would create a class for each type and define the type dependent attribute on the specific classes and the common attributes on the parent class: class Abstract...
I'm a self taught developer just in my teens about to start my first major project for myself. I'm looking for architecture advice as I want to do this the right way. I'm worried I'm overcomplicating this by building it myself when something like gRPC can maybe solve this? I'm looking for a way to have many application...
Each time a user of my APP / website interacts with the APP such that it makes an API call to the backend, the backend will make an API call to the mongoDB database to retrieve the document that holds this user's data. This user object currently sits at: Buffer.byteLength(JSON.stringify(req.user)) 9871 bytes, which is ...