instruction
stringlengths
34
36.1k
This is not a real scenario. This is just my assumption that such an accident may happen if the the following events really occur in this chronological order First, a user clicked "puchase" on an item which says "$100" on a web browser (frontend). The request is being sent to the API server. This may take quite a long...
My team works on an HTTP web server in C++. The codebase has aged over time, and has a widespread problem of 12+ parameters being passed to every function. A fake example: We need to build a Car, but in order to do that, we have the following function: MaybeBuildCar(engine_params, steering_params, interior_params, fuel...
Given a couple of entities, Invoice and InvoiceRow, I want to calculate the total amount by summing up each row's amount. public class Invoice { [Key] public int? Id { get; set; } public List<InvoiceRow> Rows { get; } = new List<InvoiceRow>(); [NotMapped] public decimal TotalAmount => Rows.Sum(row...
Going through Head First Design Patterns, and their Pizza factory example, it seems that there is no room for specifying toppings. In general, if I have a process which contacts different APIs which right now all take same input parameters, but in the future one of them might change to require more or less parameters, ...
Software A is a Node/Express application using a MongoDB database. It is accessed mostly via RESTful endpoint by a mobile app built in RN and an admin dashboard via React web app. It also has a graphql endpoint beginning to be built to replace specific REST endpoints. Software B is the acquired software solution buil...
disclaimer: I'm a university student who's one-year-new to programming. Please don't slaughter me in your responses as I am still a human being I have an idea that I want some feedback on. I am currently learning C and we just covered while and do loops. The following is some pseudo-code and an interpretation from the ...
We have a .NET Core application that works as a datawarehouse and we store our entities in json documents that we regroup by projects. Usually projects would easily have 300k json documents with 50 to 250 fields. These fields are unstructured because the documents come from several sources selected by the user and that...
In my example app there are admins and modules. Each admin may have some permissions to access a module. Also please note that I am assuming "simplified" DDD/CQRS where read models are allowed to read BC entities (entities from which aggregates in BC are "made" of). Also I am not considering event sourcing here. I only...
I'm developing a realtime chat application with an Angular frontend and Java backend. I've found a couple of examples that resemble what I am trying to achieve, such as: https://medium.com/swlh/angular-spring-boot-kafka-how-to-stream-realtime-data-the-reactive-way-510a0f1e5881 https://dev.to/subhransu/realtime-chat-a...
In Practical Foundation of Programming Languages 38 Futures and Speculations A future is a computation that is performed before it is value is needed. Like a suspension, a future represents a value that is to be determined later. Unlike a suspension, a future is always evaluated, regardless of whether its value is req...
My company has its own proprietary software that I have both built and maintained over the last 5 years I am about to release a big change for all of my software to use OAuth2 instead of handling emails and passwords ourselves. Prior to this release because I managed 100% of the dataflow, I had a feature for the admins...
I know that some languages like APL have a dedicated NAND operator, but I'm thinking about languages like C, C++, Java, Rust, Go, Swift, Kotlin, even instruction sets, etc. since these are the languages which actually implement golfing languages. As far as I know, modern processors are made up of NAND gates, since any ...
I am new to project management. I have been through a series of lectures. I am stuck with a problem and have no idea how to proceed with it. I would highly appreciate it if anybody could give me pointers. Below is the mentioned problem. I need to calculate how much time will it take and cost us to complete a project wi...
Context: analytics software The customer wants to see graphical elements A,B and C in the same area of the screen. Selecting something in A will affect B and C. Similarly, selecting something in B will affect A and C. In other words, A,B and C are dependent on each other and represent different views of similar informa...
I'm working on a project that uses Semantic Versioning. The commit history can be generalized as: Also, the current version is present in source code (so that the software can use it for various purposes). I'd like to start implementing a process that I've been seeing around: Development commits contain a version suc...
I am amazed by the way APIs of some machine learning packages are designed, namely Chainer's and Pytorch's "define-by-run" API. Even Optuna, a hyper parameter tuning library has "define-by-run" API. How to achieve such design of API? Can anyone guide me towards it with some code?
Everywhere is said that a private member can only be accessed from inside the same class, but at the same time, we can access the private member using getters and setters, therefore my question is: What's the difference between having a private member and access it with getters and setters, and making the a member publ...
In The Pragmatic Programmer, the authors write: One of the benefits of detecting problems as soon as you can is that you can crash earlier, and crashing is often the best thing you can do. The alternative may be to continue, writing corrupted data to some vital database or commanding the washing machine into its twent...
I am looking forward to understanding what software development for IoT is all about. What exactly is software engineering for IoT all about? How different is it from the traditional software development?
Currently, I have a script install_crontab.py -u <user> -c <config> This script takes care of installing cron job that runs as a given user. In my install_crontab script, I check (using sudo) if the user running the script has privileges over the user he is trying to install cron job for. If no, then the script fails. ...
I'm designing a medium size project that will have few decoupled microservices. I want to avoid costly architecture mistakes at the very beginning. What I'm wondering (I googled and didn't found any answer) is if: A) SNS topic should be relatively generic (e.g. "orders-events-topic") or B) there should be separate topi...
I have following requirements: In my system there are conferences and editions. Each edition belongs to one conference Each conference can have at most one current edition Each edition has status of draft or published Only published edition can be current edition of conference (it has to be published before it becomes...
I wonder where to add method that reads my dto WindowDto.getPath().getPoints() and based on this collections returns some value (that value will be needed in some different srevices in my app): public class WindowDto{ @JsonProperty("valid_from") @JsonDeserialize(using = LocalDateDeserializer.class) private...
I'm currently the sole programmer for a project. We are creating a handheld device that includes a screen to display live data and video feed, push buttons to control the program's functionalities, and some other electronic components. The user does not interact with the screen directly (operation is controlled through...
I have found interesting problem in DDD, which can be solved extremely simply without DDD, but with DDD looks huge. Let's say I have: Category - AR (AggregateRoot) Product - AR Category can have multiple products and also a featured product, like this: public class Category : AggregateRoot { public List<Product> Pro...
Say we call 10000 setTimeouts, each with a random time, each with a few nested timeouts too. What happens in terms of the 1 call stack, or are there multiple call stacks? How does that work? So for example: let i = 0 while (i++ < 10000) { process(`process ${i}`, randomBetween(5, 30)) } function process(name, timeout...
Say I have a business model called Vehicle. Vehicle has many fields but to keep it simple say it looks like: public class Vehicle { String ownerName; String brand; FuelType fuelType; } public enum FuelType{ GAS,ELECTRIC,PETROL } Now, this model has its own semantics in the domain. For example, thi...
The question is about a desktop application I'm creating in C# and WPF. As very common I'm using the repository pattern in my Data Access Layer for my CRUD operations. All data comes from the serverside part of the application, using a REST API. For each repository an interface is defined. So the usercode of the reposi...
I have a very basic library that serves the purpose of collecting some useful but simple pieces of code. Like for example a Percent struct or functions like ToDegrees() and ToRadians(), just to give an idea. I caught myself declaring custom exceptions that aren't used inside that library. For example a MultipleDispatch...
I'm planning to add a feature in a program chain and need an advice with rationale on the information flow. Setup DB -- binary -- artifact -- parser -- front-end available quantities I cannot radically change the chain in production, but never the less here is a brief rationale: DB stores static data Binary takes dyn...
I'm building a complicated frontend-backend application of which both the frontend and backend should be highly scalable and reusable. To serve these two requirements, I'm splitting the backend into multiple APIs where each API has it's own purpose (e.g. Registration, Login, Email verification, email etc.). These APIs ...
While writing my thesis, I am facing the problem of how to classify the testing strategies. Following section 1.5 of this thesis: If black-box and white-box are test case selection methodologies to solve the reliable test case set problem, then where to put random/systematic test case selection strategies ? Initially, ...
What is the best practice in case a service has an error which we caught and handled? Do we exit code 1 or 0?
With my team I’m facing a problem. For a hotel, we are asked to develope a cloud application that will let guests taking orders from hotel restaurant menu trough their devices. To access the menu, guest will scan a qr code (or click on a link on the web site of the hotel) and will be redirected to an authentication for...
Imagine you have to process each row in a large table. For every single row you have to download some data from a web service and store it in a different database. Loading all rows at once into the ConsoleApp's memory consumes too much resources and takes too long. It's important to mention that the table will no long...
TL;DR I have a moderately sized/complexity web application (Angular 11) in one repo and a standalone REST API (.NET Core 3 / C#) in another repo, and am trying to figure out the most efficient way to include MkDocs / Read the Docs in the project. We've been building a full-stack web application with multiple core comp...
I'm currenty building several new themes using NopCommerce, a .NET e-commerce platform using the MVC architecture. NopCommerce exposes a lot of services to you for communicating with the db, and is itself built with the Entity Framework code first approach. Overall, I think NopCommerce is pretty well-rounded, the platf...
I need your sage counsel on the following scenario that I would like to implement. I have a class that interfaces with a persistence layer (an ERP system) with a JAR dependency (in fact JAR and a DLL :() let's call him DaButler. What I'd like to do is to put it into its own webapps directory in Tomcat and make its serv...
class DomainEvent { } and then I have different events with following structure: class SomeEvent extend DomainEvent { private UUID orderId; private UUID orderlineId; private UUID productId; } Now lets say that I have 20 such events and most of them have orderId + orderLineID as attributes som have in additi...
How to upload large(mb/gb) of video files from client to app server? The solution as of now I know is pretty simple and widely used is to break file in chunks at at client side and send http post request for each chunk. Now if I take this to distribute environment, where a app server getting lot of parallel requests fr...
I am new to SE. Recently I read about the Chain of Responsibility pattern, so basically what it does is: it creates a class that has some methods and also next class (next chain block), so when it processes the data it passes the processed data to the stored class. I have seen many implementations of it, for example he...
I have a WebApi backend with a Blazor WASM frontend. The application is split up into 3 main parts. Core, Infrastructure and Presentation. Basic onion architecture structure. Core.Domain Domain objects/entities Core.Application Application releveant interfaces and CQRS commands and handlers Infrastructure.xxx Projects ...
C and C++ have standards, but support isn't perfect, the only available copies on the internet are drafts, and there are immensely useful things that aren't standard, such as __attribute__((cleanup)). Apparently the glib authors feel that's sufficiently ubiquitous even though it's a GCC extension. Then there are other ...
I've written a class that synchronizes a table between two databases using Dapper. The public and private Methods in the class are generic and the generic parameter is the POCO class that is being synchronized. var Sync = new syncClass(localConn, remoteConn); await Sync.SyncTable<myTablePoco1>(); I feel a little back ...
Following question is more about best-practices than a real problem - nevertheless, I'd like to know how to do it in best way. Given a service, that can operate in multiple countries/geo-areas, one probably start simple before even scaling is needed. A design would contain a single DB and single piece of infrastructure...
What I've read A Git repository is the . git/ folder inside a project. This repository tracks all changes made to files in your project, building a history over time. (Source) Repository: A collection of files which are kept together. (Source) A software repository, or “repo” for short, is a storage location for softwa...
I am working on the backend of a web application that exposes a REST-like API to the frontend of the application. Currently, I am exposing a "Users" resource, where each user can be represented in JSON notation as: { "id": "asdfzxcv", "name": "Morris", "preferences": { "dark_mode": true, "tags": [ "tagA"...
Let's say you have a user registration form in your frontend. In both, backend and frontend, password is valited so it has to match a set of requirements: more than 6 characters, no symbols, etc... Imagine that these rules change. Both, backend and frontend client must be updated. Does it make sense that the backend in...
I have checked many articles and discussions around the web. So we have the main diagram: So we have Controller pointing directly to RequestModel. So straight to the point, should I: Create a RequestModel class on "delivery" (is how uncle bob calls this layer) layer that implements a RequestModel interface, create th...
so I am making a website for myself. I need code about how to get distance from top to an element, and I found it from SO. I'm aware that copy pasting big chunks (a function of 11 lines) of code is not something I should be doing too much. Is it helping me to learn new things if I copy the code and go through it step-b...
I am looking to add Swagger documentation to my REST APIs but am wondering if it makes sense to add it to all APIs or not. Most of my APIs will only be used by a UI so if I expose for instance a POST endpoint wouldn't it compromise the database with bad data? I have another set of endpoints that I use to upload static ...
I'm trying to understand when it is better to pass explicit arguments to a method and when it is better to just pass self. I created a little example to illustrate the question. Here are two different class methods that do the same thing: def get_my_colors(self): colors = [] for obj in self.layers: colors...
I'm working on a system design and feel like I'm doing it wrong. Situation I have two services and they each have a bunch of data they each need. Much is overlapping data from overlapping tables. Also, I believe these services will be the sole users of these tables. Let's say Service A needs T1, T2, T3, T4, and Service...
I'm designing a project which will require iterating through a foreign language dictionary in JSON format. The idea is clicking on a word in a text will trigger a search on the JSON file for a match. As the JSON file in question is large, i.e. many megabytes in size with over 100,000 lines, what are some performance s...
The Law of Demeter makes sense in some obvious cases. # better dog.walk() # worse dog.legs().front().left().move() dog.legs().back().right().move() # etc. But in other cases it seems to lead to an interface that is too wide, and doesn't really feel like it "hides" any knowledge. # Is this worse? print(account.user()....
I have been implementing a finite state machine which basically ensures configuration of the external chip which communicates with my MCU via I2C. The skeleton of the configuration state machine looks like this: Whereas the Configure Register N states are state machines in their own. It is pretty simple state diagram ...
I think many people with even a small experience in designing UI/UX to handle user data will be familiar with the perils of putting in input field/database limits for personal data, such as names. However, when it comes to storing biometric data, such as in medical/patient management software, I might've assumed that t...
I have been implementing a software driver for an external (from my microcontroller point of view) chip communicating with my microcontroller over I2C. From the higher perspective the chip is a collection of some registers which can be read or written. This idea bring me to the following driver design: The chip requir...
Imagine you work for a financial services company that uses a pipeline to deploy new code to their customer-facing systems. Before any new code can be made available to customers, it must first go through a rigorous set of checks and scans. One check is that all of the unit tests that were written for the code pass. On...
I work at a company where we have built much of our own e-commerce platform from the ground up. We have a growing number of teams who effectively operate as stream-aligned teams, based on functional areas (Growing x capability, improving customer retention, etc etc). We have 10-15 teams containing a Product owner, deli...
I am designing out an app that would have an Angular frontend and Spring Boot (Java) backend. I was considering (but not married to) the prospect of JWT-based authentication: User logs in with username and password and submits a form; this form POSTS to, say, /auth/sign-in A Spring Security filter checks to see if the...
It may be a pretty simple question, but if I understand the concepts correctly, I can't really grasp how are you supposed to create releases with CI. Basically, if you merge unfinished branches into development branch for the CI (so everyone's code is as up to date as possible etc.), you're never really going to end up...
Generally most of the authorization in the system is done in authorization layer which then calls commands/queries from application layer, which call methods on domain aggregates. However there are several cases when authorization has to be done in same transaction where aggregate method is executed and this authorizat...
This occurred to me when looking at stencil computations in numpy. This python library compiles compute-intensive components, so I believe that it's a valid example. Here making selections on an array is done with small offsets (0, 1, -1) a lot of times. Would a c++ compiler take into account that it doesn't need a ful...
I have a scenario where user has multiple filters in a web application and a displayed list of items. In the gui it has multiple FilterGUI that he/she can tune interacting in the browser (these are React web components). Every specific implementation of the FilterGUI do the same: tune parameters and according to parame...
As my team's microservice architecture grows, as does the pain of manually deploying each individual service in the application. I've played with Docker before and am now learning to leverage the power of building images with CI, docker-compose, etc., but am overall very new to it. Question: is Docker only able to be ...
I just can't choose a method of interprocess communication that would fit my goals, so I ask for help. My list of needs is as follows: It must be safe. Communication should not be hacked. Communication will only take place between two processes. There should be no possibility of a MITM attack. The source code of the p...
I've got a validation function something like this (pseudo-code): public function validate(Thing thing) { if (thing.a != "a") { return false; // most of the time } if (thing.b != "b") { return false; // most of the time } return true; } This function is in a domain service class. I...
We have a college management system developed over a decade as and when requirements came along. The project team also comprised of students currently doing graduation in the course. These students are paid extra for work and are allowed one extra year to complete their graduation. The project also has two dedicated (n...
Now that Tesla has bought a large amount of BitCoin, other companies may follow suit. If my company wanted to do that, I was thinking about how it could be done. I'm familiar with the way private individuals store keys. I could see two possibilities: The Chief Financial Officer or someone like that would be the only w...
Background: this is a continuation of this question here, further expanding the thought experiment. In short, you have a magic calculation machine which has the following properties. The machine is: Fast. The rigid definition is that the processor frequency can be arbitrarily high (though not infinite). Finite. (NEW) ...
We have an email system that handles incoming and outgoing emails, the risk is that we get so called feedback loops, a bounce email is answered with another bounce etc. We have safeguards in place to handle this, but I need a last line of defense. I want to keep a cache that keeps track of per email how often it was se...
Here's a common question I ask myself: If I have a ThingDoer class and it has a method DoThing(), and I want to log a message stating "Doing a thing", should I put this logging code in the ThingDoer.DoThing method, or should I keep this code outside of the method, within the caller? I feel like there should be some st...
I want to use a rule engine to centralize business rules. My rules require information not typically owned by systems that call the rules engine. I don't want to complicate these systems (System A and System B) by having them fetch data from a datastore, and I don't want to customize the rule engine to source data dire...
Problem In my application a user can lock a set of related aggregate roots to work exclusively on them and to avoid the usage of an invalid set of objects later in the process (by other employees). This problem has nothing to do with the technical concept "optimistic locking", it is a kind of "domain locking". The mode...
Should each Microservice have a user account account created for each user that will have resources created for them on the Microservices? For example if there is a user profile service, should there be an endpoint for creating a user then creating a profile, or should you create a profile with a user id. The purpose o...
Given the following hypothetical programming language: Intended for practical programming A simply typed lambda calculus (STLC) All objects are functions, based on Church encodings I am aware that making everything a function means a STLC with no base types, which is impossible. I.e. this language would require an ob...
so I am struggling a bit with a database setup. I found post with similar problems, but the reason behind the answers was not what I was looking for, hence I ask again with my specifics. I am building an ER-model for a Database at the moment. We have around 10 text documents. Each document gets it's own table. Each par...
If I have two functions that I repeatedly use back-to-back, should I wrap those functions inside a new one? For example, I have: def prepare_data(data): # do a few lines of data prep return prepared_data def process_data(prepared_data): # do a few lines of processing return result These two functions always r...
I have started in a new team. I have 20 years experience as a developer, and I have been in the role of a team lead in several projects. Normally I am very much pro code reviews, but I ended up in a team that use TDD up to religious fundamentalism. Mostly this is led by a single senior resource, me being the second sen...
I have around 125 million event records on s3. The s3 bucket structure is: year/month/day/hour/*. Inside each hour directory, we have files for every minute. A typical filename looks like this: yy_mm_dd_hh_min.json.gz Each file contains subscription events in json. The subscription record has the following fields: Tim...
I am writing a function that will download an HTML post. Having downloaded the string I will: strip off the html tags remove special encoding characters like \n remove trailing white spaces My question is: should I first download all the content and then proceed with the modifications or should I apply the modificati...
I'm developing a back-end application and I ran into the problem of too many conversions between layers. For a single type it is like this: So every time I update the model, I need to update six classes and several converters. How to tackle this complexity or maybe I shouldn't? EDIT: On the second thought, after some ...
When a user signs up to a web app, they often get a confirmation email. This email will contain a link. Once the user clicks the link, the app confirms the user's account as correctly associated with said email, perhaps by changing a confirmed field on the user document from false to true. My question: The endpoint ch...
Most of the web applications that I have seen developed in my organisation , have the following components : JS App (from browser) -> Web server -> Service(s)/Application server(s) -> Database Each of these components typically does the following: JS App - The interface (UI) for users to interact with the application f...
I am a Computer Science student and one of my first class was Object Oriented Design (Java). Unfortunately, we never interacted with a database during that class. I am currently working on a CRUD app as a side-project and I am confused about the relationship between Objects and DB Tables. Let's say I am making a persis...
I have simple API that my React App can use to communicate with my backend. The API has different endpoints and 3 different versions and works like this: We have the public URL, that anonymous users can use (public.api.mysite.com) We have the private URL, that only signed in users can use with their credentials(privat...
I'm in a situation that basically boils down to storing values based on 2 ID's. The ID's are sparse, from different ID pools and pretty much unpredictable so the naive approach is to just store the data in nested hash tables. The challenge is that these values need to be stored for many sequentially created objects, t...
I am designing Classic Snake game using OOPS.I will have the following classes at top level : Game { Board board, Snake snake; } Board { Cell cells[]; } Cell { int x, int y, Type type; } Type { SNAKE, FOOD, EMPTY } Snake { List<Cells> snakeParts; } I am a little confused on follo...
I'm working on a java project for the university. The project is a card game in which you travel around a 2D map and fight against some enemies. My part consists of creating the deck and the cards. I made the card interface, an abstract card and an implementation that extends the abstract card and implements the interf...
There is an application that every day creates about 100-200 new wakelocks for android. each wakelock is used once and after using it is no longer needed, but remains in the system. Thus there are a lot of unused wakelocks in the system. How do you think this is correct? or is it bad for system performance? if you are ...
I am currently designing a communication protocol for an embedded system. I've decided that authentication (but not encryption) is important, so I decided to add 4 bytes of truncated HMAC signature to every packet. At the same time, I also want to be able to do data verification to ensure that the data arrives correctl...
I have a problem formulation but it does not resemble the usual packing problem I find in the literature but it is a usual problem in the packing industry. I just do not know the name for it. The problem formulation is as follows: I have a certain amount of objects with different weights (around 10000 objects with a we...
Apart from the memory size of both data types, I want to know any other differences and also want to know when we use float and when we use double?
We have a "workflow orchestration" system at work. It works something like this: You configure what to run (in a database table), such as: NameOfStepATHingToRun ="weather_data" RunStepB? = No RunStepC? = Yes StepCArguments = Canada,USA ... (this goes on with maybe 20 total columns) Then your configuration is run throu...
What is the most complete way to test an imperative function? By "complete" I mean, something that is robust, that tests all the edge cases of the function, that so much as "proves" it to be correct. Ideally it isn't brute force, but if it has to be that's fine. Say you have a really complicated function. You break it ...
I am a Computer Science student and one of my first class was Object Oriented Design (Java). Unfortunately, we never interacted with a database during that class. I am currently working on a CRUD app as a side-project and I am confused about the relationship between Objects and DB Tables. Let's say I am making a persis...
Reading Domain-Driven Design, on the section of Aggregates, it says The root is the only member of the Aggregate that outside objects are allowed to hold references to, although objects within the boundary may hold references to each other. The Application Layer is the direct client of the domain model. Can objects o...
Client_1 uses --> IService_1 and thus Service1_impl public interface IService_1 { void DoTask_1(); } public class Service1_impl : IService_1 { private readonly IDepService_1_v1 _depService_4; private readonly IDepService_2_v1 _batchdepService_4; private readonly IDepService_3_v1 _depService_2; pr...
I'm currently make a Helper class that can be used by multiple team members. Helper class uses third party API. And I have a question about that handles exceptions in the Helper class. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/creating-and-throwing-exceptions Looking at the link above,...