instruction
stringlengths
34
36.1k
I am building a REST API for warehouse inventory picking. I have a very shallow understanding of REST, so to me that just == stateless and try to make your URL mappings nouns instead of verbs. The picking process looks like this: Scan QR on a the shipping instruction sheet which contains an order number along with al...
My Nodejs microservices currently running on Kubernetes are communicating over REST. Does the request-reply model of NATS, which replier needs to return (large data ~ 500kb currently single endpoint response), cause performance increase? Some benchmarks say it's 10 times faster [1], but I got a bad result on a little t...
I've created a service application that import orders from an SQL database. Right now I'm manually entering the data into the database, but in release a 3rd party application will export orders to the database. For now, while in testing, I'd like to have a test software to simulate orders coming in and out of the data...
I need to make an UC diagram for a project of mine, but I don't know when to use include or extend. My actor (a Professor) can choose one of his students and do some operations (ex: see his grades), now from the diagrams I saw, my see student's grades use case should include select student , but in my app you first nee...
I'm starting to define how issues should be handled in GitLab. Most specifically whether the author should be editing the original issue to keep it up to date or use only comments. Let's say that you start working on a feature. The first thing you do is add a first analysis and design. Now one of the collaborators spot...
I'm currently building an API and a web app for an internal warehouse system using NET Core. I have the core entity structure, that goes like this: "Material" has many "MaterialSubtypes" has many "MaterialClasses" has many "Packs". Now, I need to create a list, representing a single sale. It can include lots of packs o...
Let's say that I have a list of financial transactions that I need to read in from the file. I want to make the best guess I can at what account should be credited/debited based on the transaction memo compared to past transactions. For example, if Wal-Mart was used with 'Shopping' then if a transaction that gets read ...
Is there a canonical definition of SPA which would exclude the software architecture model described below? I'm working on an app with a new web-architecture model (new to me, at any rate) which has features that differentiate it from a Single Page Application (SPA) as the term is conventionally understood. Since the m...
The application I'm currently working on is deeply coupled to the UI framework in use (Qt at the moment). I would like to separate the UI-specific code from the rest as much as possible, with the goal of creating a library for use with other toolkits in the near future. I have already started this work but I am struggl...
I have a design dilemma for a DB I'm creating for an e-commerce platform I want to develop. I have 3 different actors interacting with the website: Customer Manager Supplier Those 3 actors have the same table structure: email, username, address... My initial design for the DB was to create a single table (StoreUser),...
This question was completely reedited to be fully in line with the SE guidelines and builds on top of already given comments. I'll try to introduce some vocabulary to better describe the generic terms I use in my concrete problem setting: Source - A source is basically just a data object with associated jobs. There are...
I have a composite object (I will call it A) that has fixed number of sons (I will call them A1 and A2) All of them have an Accept(Visitor) method. I have a GUI, A is the main window that consists of many sub-windows (a.k.a A1 and A2). The visitors will be visitors for when a user clicks a button to start a new operati...
First actually I don't think Git is a specific involved tool here, it can be any other Source/Version Control tool (TFS, SVN, ...). The point here is how to deal with the scenario in which I have multiple projects, each project may reference other projects but managed by different teams. If we can include all the refer...
I have an ASP .NET web application dashboard that is used to send notifications to several .NET desktop clients. The current implementation is that the web app writes the new notification to a database and the clients poll this database every 30 seconds and look for notifications with flags marked as 'unread'. This isn...
Whenever I do temporary fix I want it to really be temporary. However, there is no way to come back to it later, as the fix might be a part of a bigger issue. Let's imagine that we have for some reason incomplete data in DB. When we fetch it, we get an exception. Temporary fix would be something like: if I didn't recei...
As far as I know, circular dependencies are something to be avoided, yet I find myself often in a situation where I've got some Object, and an ObjectManager, that is supposed to "oversee" all the Objects, and provide methods to aggregate these Object's and so on. Example: Object that has a position and can move itself...
I'm backend developer working on a very backend heavy application. So most of the business logic is writen in the backend. In our project we are considering a full rewrite of the frontend. Currently the frontend code is extremely messy and refactoring stuff takes forever. There are no tests. I'm not a frontend develope...
I'm very interested in the topic of parsers, especially in the topic of parser combinators like Superpower. The problem with them is that the grammars that they can work with are a bit limited. For instance, they can't handle left-recursion nor ambiguities. That's why I got into the tracks of GLL (Generalized LL). The ...
I am writing an API function using DRF where I want the API execution to stop if it fails in any of the steps and return an appropriate response. So I created a custom exception which takes an error code, and an error message like below. class CustomException(Exception): def __init__(self, status, msg): self.status...
I am using AWS CodeCommit with CodePipeline. I have two totally separate AWS accounts, one for test and one for production, identical Code Pipelines setup in each account, each with a corresponding CodeCommit repo. a local code repo on my dev machine. This allows me to push from the local repo to either the test ...
I've got an object with a complex hierarchy, something like: Document Paragraphs Paragraph Words Word and I need to implement a dirty flag on the Document object. In general, there can be a huge number of Paragraphs and Words, and paragraphs and words have many properties that can be changed. So I'...
What are the pros and cons of using agile/iterative approach in ETL/ELT (Extract Transform Load or Extract Load Transform) data warehouses/data lakes/lakehouses systems development? I often find that many business analysts / project managers tend to plan ingesting all data first, then building all semantic data and ot...
I have workflow where I have complex command handlers encapsulated inside aggregate. These handlers emit some events, and then further logic based on result of these events can emit more events. Sample pseudocode of architecture: public class ExampleAggregate : Aggregate { public void Execute(CommandA c) { ...
I'm trying to improve the performance of our server. We have 1 server with around 25 tenants, each tenant has it's own application instance and database. There are no performance issues, until, each instance starts it's cron job every 10 minutes. Everytime this happens the CPU spikes to 90%, we would like to fix this. ...
I have several global variables that I need to store in a database. These variables rarely change, but when they do, all installed instances of the application must updated to those changes, which is why I think the central database is the appropriate place for them. The variables are not linked to any "concept" in the...
I'm developing a new application that allows the user to do many writes. Therefore, it is very inefficient that we use our server-side to handle every write request by users. Should we allow users to write to the database directly, without going through a server process? we're using Firebase so we can write security ru...
In "MVP Passive" where a view doesn't know about it's presenter the view just raises events observed by the presenter, the presenter knows the view and its controls how should view and presenter properly function/communicate with each other? I.e through methods, disposing of view/presenter, interpresenter, other view...
I work in the SAP industry where web-based UIs and RESTful APIs are a rather new thing, meaning some teams (like ours) don't have much experience in designing such systems. Recently there's been a dicussion that revolved about whether our API should be an abstract representation of the resource or client-specific by pr...
SQL Server documentation uses this notation, which is very easy to understand and consume. Is this a BNF Syntax Diagram? Or is this a different type of notation? Source: SQL server documentation page with the original diagram
I have been reading some old design books (SSADM, JSD.etc) on software engineering that deal mainly with a procedural view of creating systems. I was just wondering if we still use these old techniques e.g. splitting into subsystems and modularization even though programming languages at the moment is mainly object bas...
I'm working with services and I found out there are at least 3 ways to use them inside controllers... Statically: Like helper, Text::uppercase('foo') Instancing it: $text = new Text(); $text->uppercase('foo'); Injecting with reflection through parameters: public function(Text $text) { $text->uppercase('foo'); } In...
Question In the context of an MVC, desktop architecture, is there a canonical solution or a design pattern / best practice to give access to an immutable value class to multiple components at different levels of nesting? Use case examples: User settings: Some controllers or views need to access the user settings so th...
Given the same application written with multi-threading and async IO, will async IO use less power on a computer?
I am designing a test for an existing static method: public static boolean hasPermissions(String username, int pageid) { PermissionsService s = new PermissionsService(); int[] pages = s.getPages(username); for (int i = 0; i < pages.length; i++) { if (pages[i] == pageid) return true; }...
Sorry if this sounds like a stupid question I’m very new to this. So my question is; within modern computers memory address space is a byte long, so what would happen to the rest of the address space if left unused as some data types like booleans use 1 bit of space. I understand slack space within other block devices,...
I'm working in a team that won't approve my pull requests until the entire Jira ticket is all included in the pull request. Sometimes the Jira ticket has a huge scope that would otherwise be a dozen different pull requests. They consider my code wrong until it's 100% complete with every single additional feature. This ...
I've been working on a project that communicates with a service which sends very complicated REST responses. Current "best practice" on this team is that we use POJO DTOs to handle all data transferring. If we have a GET endpoint, it returns a POJO DTO, if it's a PUT endpoint, we only accept data that fits a DTO etc. T...
I have a server application that runs in an infinite loop, only reacting to SIGINT. It is put inside a screen process. If I have to make any changes (reload configuration, add new plugins, etc) I simply restart the whole process so the changes are picked up during initialization. I'd love to refactor the application so...
After years of (amateur, dirty) personal API development I finally decided to follow some best practices. My problem: the API may have problems, say, retrieving some data. It will gracefully handle the problem but needs to pass that information back to the requester (a JS front of mine, if that matters). My question: s...
In Kotlin or Java we have many different types: integer, byte, double, long, float, string, character, etc. But one can use an integer instead of byte, and a double instead of an integer. Why we need all those different type? Why we can't just have a double, and forget about integer, byte, float, etc.?
I am working with a very large SQL database through a frontend reactjs application with a node server intermediary using an ORM for query sanitation. However due to the size of the DB it takes some time to search through, sometimes up to 15-25 seconds which makes my react app incredibly slow for the initial load. I h...
My application provides the following resource: GET /user/:id/orders As commonly used, this returns a list of all the user's orders. Now, a client wants to check if a user has any orders at all without actually getting the complete list. My current approach looks like this: GET /user/:id/orders/exist But it looks kin...
In standard POSIX locale strftime(buf, size, "%c", time) will format the date and time in an order that has confused me a number of times because it has month and day precede the time, but year follow at the end. Example (from ccpreference): Sun Oct 17 04:41:13 2010. Since this appears to be a POSIX specification, the ...
We have a microservice whose multiple instances are running for High Availablity and Scaling. But although we have multipe stateless microservice there are some tasks which needs to be singleton. For example, let's say we have to fetch emails from multiple email Ids and do some work on those emails. Now since I would l...
We are using git flow as a branching model, and we have a feature ticket that conceptually is a pretty small feature in the software management tool, in this case Jira. The thing is that the code on the feature seems to be big enough to have it all in one PR, and we can't divide the ticket in the software management to...
I am creating a bank software system. In this system, there are 3 account types: Savings, Checking, CD. Each account from any type has an ID, apr, and amount, and we can withdraw from it. So I can have an abstract class Account, that contains ID, apr, amount variables, and withdraw(int amount) method. But, we can depos...
Consider the following GUI screen (Java Swing) with a list of persons where the user can select a person and delete it. According to MVC, the view observes (observer pattern) the model and updates itself. Business logic and domain data in MVC goes to model (as far as I am aware of). My question is, should the model be...
As a beginner to web applications and front end stuff, I'm really confused about if it's good practice to use the Django template system and its admin interface in commercial applications. As far as I know, the modern approach for web apps is to modularize them between a back end and a front end. It seems that this mod...
Let's say I have 2 variables dir_name = mydir and file_name = file1, each to be used in formatted strings. There're a few ways to insert a / in a string with those 2 variables. dir_name = mydir/; file_name = file1 dir_name = /mydir; file_name = /file1 dir_name = mydir; file_name = file1 With Python, there are 3 commo...
I'm working on loading PNG files. I know there are existing libraries, but I'm doing this for learning purposes. Previously, I was using LodePNG, which is a great library that performs really well. I have a large PNG, 2048x2048 pixels with 8 bits of depth. I load it ten times with my code, and average out the time it t...
In the online book "Introduction to Modern CMake", I found the following recommendation: Do not use global functions: This includes link_directories, include_libraries, and similar. Yet the only 2 use cases I've seen of CMake in are: make a couple of libraries and a binary using them OR compile a simple binary (fetch...
How are physical memory addresses actually determined or 'created'. What is the process where the byte blocks have a memory address assigned to it? I understand that this is determined during boot up, before the BIOS is executed. But not exactly sure how or what the process is.
I found previous SE questions like this. I'm familiar with the typical RDBMS backed MVC web app framework. To illustrate what I am thinking of, let's use the examples of Bunny and Carrot from this [article]. In a typical MVC For a typical MVC RDBMS, you would have two tables. A carrots table and a bunnies table. Whic...
I am working on a grade management system web app for a university and I came up with this database schema How the app work: In the user table I am going to keep all the users data and the id_user_data will tell what kind of user is(student, teacher or administrator) The administrator can add new users, new specializ...
In our codebase, having precise management of memory, data was being passed around like so: typedef struct { size_t const sz_size; size_t sz_len; int32_t * const restrict pData; } S_ARR_T; int32_t highLevelAlloc[DATA_SIZE]; S_ARR_T sArr = { .sz_size = DATA_SIZE, .sz_len = 0U, .pData = &highLevelAlloc[0] };...
Our main (C#) application: takes in parameters and starts working (batch processing, takes anywhere from minutes to hours) up to x instances of said application per server instances are started by users from our front end by making a request to a "master" on a server (really bad load balancing is just one of the probl...
I'm working with a client who currently uses a database system that they've outgrown, so we're re-building it using a different platform that can handle their growth. One feature of their current system, built into the platform, is that updates to data are automatically propagated to others viewing the data in real tim...
I have a collection of documents, which hold a subject id, a timestamp and a value. For example: { sid: 1, t: 3, v: "A" } { sid: 1, t: 5, v: "B" } Which means subject#1 is measured to have value A at t=3. Later, at t=5, value changed to "B". Only when a value is changed, a new document is inserted. My goal is to k...
I've got the following: Clientside C# application. Contains forms for CRUD operations. It uses an API for all data operations. Input is validated on the client, and obviously also on the server (API). I use the repository pattern for calling my API. That's because I want to communicate with data layers via interfaces, ...
I'm looking for a clean solution to share types, endpoints and response format between a backend and frontend. The backend will be in Python & the frontend in Typescript. The backend is a REST API. Ideally, we will have a code & architecture as follow : - backend/ - ... - frontend/ - ... - config/ - types/ ...
I'm working on a project in which I have a clear separation between domain logic and the logic that exposes these features using an API (or whatever). For this I'm using the Onion Architecture. Now I want to implement authorization. E.g.: If the user is the manager of an employee, he can update their salary. But not fo...
I have Orders which are raised against Contracts, which can be set up as either a fixed price contract or as per price per contracts. During Contract setup, allowed Products are assinged as ContractProducts. For fixed price contracts, ContractProduct is set at the Contract level, while for price per product Contracts, ...
I have a class whose instance variables should be initialized from a file ('settings.json'). That file does not always exist or is sometimes not filled with useful values, so I have to check for that first. I am now wondering what the best practice would be, I currently see two options but I am open to better ones. Ch...
I have an idea to use gRPC for all microservices communication for the sake of simplicity. Now there is a service that needs high availability, So the idea is to use RabitMQ as a message receiver from the outside. Question: Do we still or possibly still preserve high availability by using gRPC as a transport layer for ...
I am asking a question about the overall architecture between different projects. Let's say I want to centralize all icons / images between different projects in a single repository. This means that all projects need to checkout / synchronize with this repository. I am going to use SVG graphics to make sure that I can ...
My apologies in advance for a question that might seem trivial - I am a mostly solo dev in academic environment and a lot of industry best practices don't necessarily make it here. Several of my projects run high-performance numerical computation loops. Per se, a single iteration of the loop is rather fast (~1 sec), bu...
Let's say that in a project we have a function (in PHP for example) that checks whether a particular user is eligible for a discount. Also, we have a report (written in SQL) that pulls all users that are eligible for discount. At the beginning of the project, the logic in the function and the SQL is identical, no issue...
I saw an answer on SO which said that just having a class with methods doesn't make it OOP and that it represents Class Oriented Design. I'd like to hear the differences between Class Oriented Design and Object-Oriented Design also want to know how can I sense Class Oriented Design in a codebase?
I'm creating an inventory management system, in which the program needs to handle a lot of different equipment, with the possibility for the product owner to increase the selection, without having to change the code. Some of the products that might need to be included in the application is: Transistors Wires Drones Ra...
I'm currently working on a web app using ASP.NET Core (C#) on the backend and Next.js (TypeScript) on the frontend. I have a lot of forms that need to be validated and I don't want to write validation rules for them twice because it will be a hell to maintain and keep them synchronized. So I want to kill two birds with...
I'm studying asynchronous IO, concurrent models for IO and how things works on windows, linux and most used web frameworks. I'm struggling on understanding why single-threaded event loops like the one used by node.js or ngnix, in case of handling requests that wants to make an IO operation (let's say an HTTP request to...
I'm currently trying to solve a problem with some legacy code that makes some calculations in order to find out the final value of a monetary benefit. The legacy code uses an imperative approach with lots of if and elses to handle calculation rules for each kind of benefit, which I believe will be hard to mantain and r...
Little History, I used to work directly for this company a few years back. Due to budget reasons I decided I needed to move on. however I maintained as a part time contractor to keep the lights on. Within the last 6 months they asked me to contract full time complete a pilot program for a new product. I know the hi...
I would like to create an application that will interacts with an online database and i want to host my own online database on an old computer, but i think that in this case i should handle the security and other thing by myself. The problem is that i don't know if this i'm able to handle this stuff. So it's something ...
I have read DDD Vaughn Vernon book. There is a info about CQRS architecture. He mention that Handler can only do one Handler task, which I understand his and he cannot invoke other Handler. And even If i skip that and I invoke other handler I can't return value to connect them like with keys. So I have this kind of pro...
I have two separate, isolated Domain-Driven Design contexts, and have a feature that needs to be implemented to integrate them together in some way. Both of these are broken down in a Hexagonal/Ports and Adapters style. The feature is implemented using an Event Subscriber, with an event messaging mechanism for communic...
Lets say we have a microservice architecture consisting of: multiple frontend clients, e.g. an Android App, an iOS App, and a Javascript Web Frontend a Java Spring (HTTP Rest) microservice to access user data a Java Spring (HTTP Rest) microservice to access application data a keycloak authentication microservice Lets...
I saw a code example online that uses adapter pattern as: if you look at the HR system, the employee information in the form of string array and the ProcessSalary method of the Third Party Billing System wants to data in List. So, the HR System cannot call directly to the Third Party Billing System because List and ...
I'm defining some binary formats to encode some information and dump it to a file. I want to place a MagicNumber/Signature at the beginning of files encoded in my format to be able to tell them apart from other types of files. My question is: How do I choose a good signature? I've been thinking about picking 4 bytes th...
I'm trying to code Star Trek The Dice Game. The basic concept is you roll dice, which become different types of crew (Science, Medical, Command, Engineer, etc...) and you can "spend" crew to take actions (heal people, transport people, raise/lower shields, cause the ship to travel, repair the hull, etc...). The game ha...
As per the "Accelerate State of DevOps 2019" (you can download it here) they define lead time for changes as: how long does it take to go from code committed to code successfully running in production? I wonder how should you calculate this when you have multiple commits because I see at two potential interpretations...
I recently started researching about coding, but there are a few things that made me confused. I chose Visual Studio Code to start coding in C and Python (I was using IDLE for Python before), but afterwards I learned that Visual Studio Code does not contain compiler or other components that I don't know what they do, s...
I'm a developer on a website which has a server which serves HTML and another server which handles API requests. I use a CDN to cache both the HTML and API responses. I feel that it gives me all the control I need while keeping the cache settings in one place. If I make a deployment of new website version I just invali...
In my organization there is a release cadence to deploy any piece of code to Production environment. We have three environments, Dev, Test and Prod and we have deployment in every 15days and the dates are pre-defined for an year. For Eg: For 2021 we have Prod Releases on 2021.06.15, 2021.06.29, 2021.07.13 ... so on. Me...
The usual approach is to do what libraries do: group your (single file) classes by component where folder = namespace, right? That makes sense for code that is mostly meant to be used by other projects. But wouldn't it be better to structure your actual application by inheritance? The major benefit would be that just b...
I have a fun problem ahead of me. So, I have built a solution for my company that basically handles unstructured information. It works like this: A user creates a Task, the Task is in reality just a collection of Tags. These Tags can hold any type of value. So, for example, if a user wants to create a Task that holds a...
In my app I have items which are dynamically created based on an UI editor. The item details is a JSON. The domain does not interact with the JSON details. The UI is responsable to create and render the details. public class ItemDto { public JObject Details{ get; set; } // JObject is Newtonsonft.JObject } public...
I need to put data from MongoDB together with tracking data from a quiz app (stuff like which users clicked what button etc). Then I’ll use this in machine learning. I looked at all the DW options such as BigQuery, and I’m asking myself if a SQL database wouldn’t be enough. Is there a general strategy to evaluate when ...
I've got a race condition problem I need to solve with a distributed API/service and would appreciate vetting my plan and any fresh ideas I have missed. Problem: I have a finite amount of many (hundreds) different resource and need to know when each has been used up. The resources are consumed via API calls to a distri...
I'm building a backend following the CQRS pattern and I don't know how to manage properly the primary keys (surrogate keys) between the command and query databases. For example: I have a model with two different tables in each database. When I want to update the model in his different tables, each one doesn't have the ...
Suppose we have 2 microservices - service A and B. These two services are independent for most parts and API client talks to them directly. However, their functionality overlaps or intersects in some areas where we need some info from service A first, then provide those info to service B to get some other info. To save...
I know this is a theorical question since i don't have code to or any logs to show, but i hope that someone can give me some idea on this question. The problem in question was the following: On my work, on a deploy to a production system a migration took so much time running that it failed due to a timeout and this hap...
I'm a beginner in C++, and I was wondering if it is best practice to define a member function directly in a class, such as: // something.hpp class C { inline int func() { return ... ; } } rather than the usual: // something.hpp class C { int func(); } // something.cpp int C::func() { return ... ; } In my read...
While writing python code (I write python-selenium for GUI automation), I am facing situations wheer I have to deal with 5 widgets that do the same thing, just there xpath is differs by one term. # set value of a type of web element to x try: if not some_web_element.checkExists(): report('X does not exist') so...
I'm building a lot web applications for internal use, my setup is basically ASP.NET Core, React/Angular and Typescript. I started to find my self duplicating a lot of code from C# into TypeScript types and found this nice little utility https://github.com/pankleks/TypeScriptBuilder that will create TypeScript-models fr...
Consider the following scenario: If the user isn't registered in the database, register them. Return their ID. If the user is in the database, return their ID. The API endpoint for this may look something like POST mysite.com/api/users?LastName=Stack&RegisterId=1111 The consumer of the API does not want to first GET ...
UDP is an example of an unreliable protocol. Is there a single word that means "okay to send via an unreliable protocol?" Sort of like "unimportant", but that's too strong a word. The context would be the name of a message property where the application cares that certain messages are delivered reliably, but is otherwi...
I am modeling a ship that has contracts. Each contract can either be a fixed rate contract which pays a set fixed amount every day or a market index contract which pays an amount that varies based on a market index. I hope to run simulations on each ship where I would provide required information on what the market ind...
If reading uninitialized memory is undefined behavior anyway, why has the C++ standard not been changed so that objects of primitive type (int, unsigned, float, double, bool, char) get default-initialized to 0? Wouldn't this prevent an entire class of typical beginner mistakes? From my understanding, it should be possi...
I'm reading about BroadcastChannel API https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel . It seems that it is already on market for a long time, and quite cool as well. However, what still bugging me is any practical use case that we really need this BroadcastChannel. Appreciate if there is any real li...