instruction
stringlengths
34
36.1k
While building microservice-based architecture I came across a dilemma on how to approach company level permissions for given range (or ids) of resources, i.e. allowing certain users to access subset of data for the company that the person is working at. I have number of services, Invoices, Company, Orders etc. Each se...
When working with functions that run a few short "procedures" in sequence that are not used anywhere else and it makes sense to keep it all inline, in a single function, a large part of the code often ends up being separated into pairs of variable declarations, and then certain blocks where said variables are properly ...
If we program to interfaces various parts of the implementation can be effectively hidden. We can define multiple interfaces for a single implementation and use them as needed, instead of 4 fixed levels (public, protected, package protected, private). From this point of view Access modifiers seems redundant and limite...
We're looking for a scalable way to implement a file browser feature backed by a robust object storage system for the files. We were looking at an S3 compatible service, such as MinIO for this. Since these files will be accessed by other features as well, we thought of giving these objects immutable unique ids, indepen...
Should a service making a request send all the information another service requires from the requesting service to complete the requested service's job? Or should the requesting service send as little information as possible when making a request and let requesting service decide what additional information to call bac...
I want to assign Python variables imported from a JSON file. This question had an interesting answer using a classmethod, but I couldn't get it to work and I'm not allowed to comment... So, let's consider a really simple example: I want to evaluate z = x^2+y^2 but I want to be able to define x and y in a JSON file. My ...
REST APIS are a Uniform interface. Is it better to add functionality to the search parameters of a GET request with a query parameter, than to add nested resource identifiers to a collection /exists or /exists/type. Must resource identifiers have database entities unlike /exists or can they return results from domain e...
Say that you have a monitoring application that reports downtimes for a large number of remote systems (think IOT). A monitoring daemon polls the remote system and reports that status (on/off) via an event stream to an event processor. The aim of the event processor is to determine when and for how long the system was ...
I want to store and analyze university course requirements. Lets say, students to register for ABC123 course following requirements should satisfy. Must pass CBA321 Should be taken with XYZ123 Must complete EFG456 Should have passed 20 credits. Here I have hundreds of course and similar requirements. My questions are...
I'm not sure if my answers to the following exercise is correct: Suppose the program is run with two threads. Further suppose that the following sequence of events occurs: Time Thread 0 Thread 1 0 pthread_mutex_lock(&mut0) pthread_mutex_lock(&mut1) 1 pthread_mutex_lock(&mut1) pthread...
I'm going to write a blog app for myself, and though I've written authentication for multiple users. It seems heavy handed to use the same kind of architecture for one user. The only alternatives to having a table/document with one user (myself) for auth would be an environment variable to check. However, I'm not sure ...
I have this order: class Order { long Id; string Concept; string Comments; //another properties UpdateConcept(string paramConcept) {...} UpdateComments(string paramComments) {...} } In the domain entity, I have to have one method for each property that I can update. But my doubt is in the applic...
I am creating a simple P2P file sharing system, where one peer can send some Objects (e.g., String, custom objects, etc...) to another peer. The peer, that receives the Object, can then manipulate it, extract information from it and store it. To receive and send objects, the classes Sender and Receiver are used, and th...
Recently I was trying to use PHP's array_udiff() function to compare a value in a multi-dimensional array with a plain old string value. I tried something like this: // E.g. $employees[0]["name"] = "Jeff"; // $currentEmployeeName = "Steve"; // This won't work because $a doesn't always correspond to $employees arr...
I have a multiple same tables (14 for now), with a only foreignKey column difference. Some of them are: DatasetGraphTable +-------------------------+----------------------+--------------------+ | datasetID | parameterID | value | +-------------------------+----------------------+-...
Suppose you need to design a drawing program that relies on a geometric kernel library. Inside the geometric kernel library, you have the definition of Line, Circle, Ellipse classes with all the geometrical data (position, radius) and functions (area, perimeter, tangentAt). The actual program should extend these geomet...
I know there are already questions about file structure in MVVM but I haven't found the pros and cons for the following two structures. What would be better for a large-scale project, and why choose one over the other? For example: In the first example both modules are dependent on projects from 'Core' and it would be ...
I'm interested to build a VR app which will allow the user to interact with some 2d screens in a 3d world. I would like these same 2d screens to be available on a mobile app, so that the user could use them either from their iPad, or inside the VR too. My first thought was to create the ui in flutter and build the apps...
With C# 9 and the introduction of record a lot of boiler plate code was remove from pure data objects. And after watching a dotnet community video on YouTube where then "joked" about it's time to have more than one record in each file it made me think. I have a bunch of records that are basically data bearers in API co...
As all articles say the Virtual DOM is lightweight and allows us to update only those nodes that has to be updated, unlike the real DOM that updates the whole nodes structure. So the first question: how is Virtual DOM lightweight? Since it can't affect the nodes structure I assume VDOM does not have some methods that t...
Context Suppose there is a e-commerce microservice architecture with the format: In summary, a client will contact the Auth Service / Identity Service to receive a token. It passes the token to the API gateway, which verifies the token, and forwards the request. That being said, there are services that need to be acce...
It's common to implement optimistic concurrency control in DynamoDB by giving each item in the database a top-level "version" attribute and only allowing an update of an item to succeed if the current version matches the expected version (see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapp...
I have a question. I want to add 'period' in the database. A period would always be 1 month. How Would I be able to make calculations with the period? For example I want to calculate the following: A = Last day of Current Period - Last day of Previous Period How would I be able to make the system understand what the l...
Good afternoon. My situation is this: I have to call an external API to create some data and store it there, but I want to have a summary of that data in my own database. I have my use case that creates the AggregateRoot and my port interface that the implementation calls the external API. Where should I put the databa...
I have a python/php background and just about to start work on a NodeJS project which is why I have this question. I have worked a bit on frontend JS but this is the first time I will be using JS for some backend work...I fully understand and appreciate the asynchronous nature of JS when it comes to frontend developmen...
I'm building a web app that will integrate with the Etsy REST API and persist information in a database for things like order information, listings, etc. Essentially a panel to manage Etsy orders and products. What I am currently stuck on is how I should architect the backend API. Currently, my backend is structured in...
Question What is a good storage layer, coding paradigm, and query language for computing over realtime data? Use-case For example, stock and options prices are (essentially) realtime data streams. I want to load that data into my storage layer every N ms, compute a set of strategies from the data, and surface strategi...
I've written a web scraper and would like it to run as quickly as possible. The scraping isn't trivial; I scrape a few web-pages, gather links from them, scrape those, then gather links from those, then scrape those again (illustrated by the three different functions, showing the process to be multi-level). Since stand...
Imagine the follow basic (abstract) setup: 1 API Gateway -> GWAY 2 Auth service (i.e. keycloak) -> AS 2 Location microservice(s) -> LMS 3 Activity microservice(s) -> AMS Every microservice would have its own database and is subscribed to a topic to consume events of interest. The LMS manages the user location read & w...
I am finding the minimum value being input from stdin. For example, 1 5 3 2 -6 7 should return -6 to stdout. My question is if it is a better practice to initialize my minimum value to INT_MAX or to the first scanf call. #include <stdio.h> #include <limits.h> int main() { int min = INT_MAX; int input; wh...
I have a system that uses event sourcing. https://laravel.com/docs/5.8/authentication#remembering-users I'm trying to replicate the functions of the basic Laravel authentication. However with event sourcing the remember me token seems a little strange to add the event stream. In the normal functionality its stored in t...
Given the following design from clean architecture in which layer would you put overall application state? In each state a subset of use cases are allowed to be invoked. For example if application is in "Updating" state invoking AddNewParameterUseCase is not allowed.
I recently finished developing a piece of software in python where learning models and data processing procedures are contained within different class objects that succeed to each others (modules). As I'm new to standard practices in software development, I would like to know the followings: Should I apply unittests t...
We are planning a complete rewrite of a very complex project (10+ years, ~15 different application modules) and we would like to adhere to DDD and CQRS as much as possible but we are struggling to fit our needs. The context The app is a data-analysis tool that basically stores data and allows the user to configure cust...
Suppose I have a DB schema with two tables, a Student table and a Subject table. The relationship between these is many-to-many, so I also have a StudentSubject join table. Now suppose that, periodically, there is a new subject and all students must be enrolled into this subject. Is there any sort of clever insert patt...
I am working on re-platforming and migrating to microservice from an old monolithic application. But I need a way to measure the success and progress of the project. The things I thought about are: Measure the amount of code being deleted in the monolith Measure the number of calls that go to the old system vs to the ...
I'm creating a time registration application for employees where they can register their hours. I want to show the users their "norm" (not sure if this is an actual word or just made up by my company). The norm is basically the number of hours someone has to work in a week. For each week in a year, I have to show this ...
I'm currently working with a group of developers (as outside contractors) on an existing codebase (in kotlin) and the lead dev (the client) is blocking merging of pull requests (GitHub) because methods and variables in any given Kotlin class are not "alphabetized". Only some of the classes are currently alphabetized in...
Let's consider an entrepreneur decides to create a new company like Airbnb, Netflix, etc. The problem is about the software part. He doesn't know how long it takes to create the mobile/web app? How many frontend developers, backend developers, devops engineers, graphic designers, etc. are needed to be hired and work on...
class Product... public static Product newWordProcessor(String name) { return new Product(name, new CompleteRecognitionStrategy()); } Martin Fowler presents this code in his book "Patterns of Enterprise Application Architecture" on page 122. Does this work in the real world? When is Product constructed? Where is thi...
I am working on a C++ application which lets users work on projects. Each project consists of several files that should not be known / edited manually by the user. For that we currently use a folder structure to store the settings, the files created by the user in the app and some automatically generated files. We woul...
I have thought of this for a while and I want to know what you think about this. This is more of a way to structure the code that might not be 100% object oriented and that is not the purpose. I would like to divide the code into Data, UseCases and HelperMethods Data should be more clean (or "anemic", if you will) obj...
I have a service that use a worker to run a periodic task. I will not use a concrete language because it is a generic question, so I will expose the general idea. MainProgram { Worker.Start(); wait worker; } Worker { Execute(cancelationToken) { try { while(!CanelationToken...
I have a static class in my code that has two methods that store different data in a SQL database when they are called. In each of the methods I open a connection to the database. Is this the proper way to do it or is there a better way to do it? My Code using System.Data.SqlClient; namespace Asm { internal static...
Why would so many repositories use additional — apparently unnecessary — vertical and horizontal space in coding styles? I almost unanimously see this: public function getName() { return 'webauthn'; } public function newKey( array $data = [] ) { if ( empty( $data ) ) { ...
I've made an endpoint for creating events: POST /events/new The request should have JSON data on the body. This is the JSON structure that is required for creating a new event: { "label": "my first event", "description": "lorem ipsum dolor sit amet", "meta": { "status": "draft", "isOnline": ...
I arrived in a project and they have 2 instances of a microservice. Each instance running in a 16gb RAM + 4 CPU setup in AWS (using Kubernetes), horizontally scalling up to 4 - 6 instances at peak days, but normally, 2 instances are enough to deal with the throughput at most times. I didn't saw any problem with this se...
By definition, a pure function is deterministic + no side effect. Is there any example for a function which has no side effects, but is non-deterministic? I.e., a function without side effects, but not pure. To me non-deterministic function comes from randomness. But random generator has side effect. AFAIK random gener...
I've to store a static pdf with an user guide of my application. I'm using Spring boot and Angular 12, what is the best way to store it? Put the file on resource folder of Spring boot? Put the file on asset folder of Angular? (I'm not so skilled in Angular, I don't really know if this is a valid option). Create a bran...
Imagine there is a stream of requests for about 500 types of work. There can be say 5 workers in parallel. One type of work should be executed by at most one worker at the same time. The requests for a specific type of work should thus be done sequentially. So further requests for that active type of work should be enq...
I'm working on my first big system design project at work for the first time in my career. In the past, while i've worked on large systems, I was always working with someone else, so I wasn't really responsible for design, I just understood the choices the made and pointed out potential upsides/downsides on specific th...
TLDR: I am trying to validate a Azure AD B2C access token in my Flask web API use scopes from that access token to authorize calling protected resources use timely and secure solutions such as PKCE for OAuth 2.0. what already works: [ client app ] -- authenticate & get access token for api --> [ Azure AD B2C ] OK [ c...
Here's a ubiquitous data structure in, say, game and UX programming: there're a fixed number of items (say, "5") they're all "zero" to begin with you can put one in on the "left" (FWIW I usually call it something like shove to distinguish from the usual meaning of push) once there are 5, each time you put a new one in...
All guides and blog posts that I have read about dependency injection use a simple example where one object A depends on one object B. They apply DI by creating object B somewhere else and passing it to A via a setter/constructor, instead of having object A create and maintain object B directly. Such examples, however,...
I am going to type out my problem in terms of my domain use case; When an Operator has an Ingest with a valid Dataset (Lowside, Drive and EntryPoints selected), they will opt to then Scan the Ingest. The Scan will run over all the EntryPoints in the Ingests Dataset. A series of antivirus and content scans will occur - ...
I have a python script that is supposed to be used as a small cli program. This is google's recommendations on how to document cli syntax. I was wondering, are there similar recommendations, or specifications, perhaps from GNU?
UserA and UserB are signing up for some joint service together. They both have to independently agree to T&Cs before sign-up is complete. Once complete they both receive an email to sign-in. A 1 or 0 is being stored in a MySQL table (TC_ACCEPTANCE) to indicate T&C agreement for each user (USER_A_ACCEPTED and USER_B_ACC...
I interessted in the "usecases" and "how they interacts with the "context" at "clean architecture". If I understand right, there will be two contexts. First is the context of the domain-model with instances of the intelligent domain-entity-classes, which are includes all the buisness/domain-logic (e.g."Client") Secon...
We're building a service using DDD, CQRS, & Hexagonal Architecture that allows the user to upload a CSV feed for which every row will be transformed and sent to a third party over HTTP. We have two aggregates: Feed & Delivery. Feed contains original entries from CSV and Delivery contains payload, status, and fail count...
I'm learning the Rational Unified Process (RUP) in a software engineering class. I cannot figure out the difference between business modeling and requirement. In the business modeling step, we need to define the business unit, find business actors, and draw business use cases. In the requirement step, we need to define...
In Python it is very common to see code that uses method chaining, the main difference with code elsewhere is that this is also combined with returning an object of the same type but modified. This approach usually assumes that objects are inmmutable and only new instances are returned. The question is whether that vio...
Git commits contain pointers to their parent commit(s). Is there a reason why they don't also contain pointers to their child commits? I get that there's a problem of data duplication, in that you'd have to update both parent and child commit objects. But apart from that it seems like there'd be an advantage in terms o...
I have a few methods that are used from different class tests. Also, some other common methods are used for preparing the test data. What is the common practice to handle this in tests? Should I handle this like any other case by having either base class or some static class (e.g. Utils.CommonMethod())? I use static cl...
I am trying to migrate to Jetpack DataStore from good ol' SharedPreferences and there is one thing I am struggling to come to terms with and that is the amount/size of the data pulling out of DataStore at once. SharedPreferences were asynchronous and it was usually used in a way that they had one accessor with over exh...
I came across Environment Diagrams,it is described below Whenever Python needs to work with an object, that object is stored in memory; and, additionally, Python also needs a way to associate names with the objects it has stored in memory. And so there will be two important categories of things for us to keep track of...
I am trying to parse a file created by another software, but I cant identify a pattern on how this datetime is saved. There doesnt seem to be any consistency. Programming language of the software is C++, so I already tried the unix/epoch method without success. Maybe someone does recognize a pattern or can give me a hi...
I am writing an application where a user will have a custom config json file. The json is just a dictionary where they define new objects of the exact same type. Here is an example with outfits: 'summer' : {'footwear' : 'flip-flops', 'bottom' : 'shorts', 'top' : 't-shirt'}, 'snow' ...
Consider a card game (something like Magic or Legends of Runeterra) program, with BaseCard, Deck and GameState classes/structs. The way I've conceptualized the relationship between these classes would be something like this: BaseCard.hpp struct GameState; class BaseCard { public: virtual void DoEffect(GameState &g...
I'm planning to port or rewrite an MFC GUI C++ app, to use in a GNU/Linux environment, and hopefully make it cross-platform. The app has few, if any, dependencies other than MFC and the standard C++ library. The thing is, I have very little experience in GUI app programming, and in programming for Windows. My question:...
I have several questions related to CQRS in eventually consistent systems with a need of resilient Command/Event processing. Is it OK to have external/public synchronous Commands (triggered by API, e.g. RequestUserCreation) in conjunction with internal/private asynchronous commands (triggered by events, e.g. SendWelco...
Why learning about Fluent Interfaces, I came across this post which states that using set hints one is mutating the object whereas with is returing a new object. I have seen this pattern first hand while using PySpark (Python API for Apache Spark): # Using "set" to modify exiting object from pyspark.conf import SparkC...
coders. I'm learning C programming language and found out such thing as #define directive that allows us to use symbolic constants (following Brain Kernigan). I know that this directives "insert" literals or expressions right into code. Their purpose, as I understood for now, to get rid of magic numbers in a code. Also...
I have a scenario I am considering, and I don't quite find out what's the best solution with OAuth. Hopefully I can learn good things here. We are company A and we specialize in managing secure text notes. They are company B. Company B has users that access Company B site. Sometimes they authenticate, sometimes they d...
Context Suppose one has a list of algorithms, which each have a multiple run/parameter configurations. Next, one wrote a generic function def get_mdsa_configs(self) -> List[MDSA_config]: that returns an list of all the possible run configurations of an algorithm. However, as you can see it currently returns a list with...
I would like to have a class, let's say a queue, that can be specialized to its behavior. For example, let them be a SafeQueue (which disables IRQs before any access) and a FastQueue (which doesn't). As you see, the vast majority of the common code would be just the queue itself. Please tell me what you think about the...
I am reading this article about using DI inside ASP.NET Core @ https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-6.0 .. but i can not understand its benefit of providing abstraction level. for example without DI, we will have those classes:- public class MyDependency { ...
My system consists of 4 seperate layers. API layer Application layer Infrastructure layer Core layer System is not Domain Driven. It contains no entities with domain logic. All models are anemic. System uses third party SDKs to do CRUD actions on external resources that are not owned or managed by me. Commands and qu...
Objective: Designing a data intensive application(myApp) C++ on Linux/RTOS which runs on a single core cpu, there are also 150 other applications share the same core with high priority than myApp. How the system looks: more than 150 C++ applications share the same cpu core and most of them have high priority than myApp...
I've been looking into the Modular Monolith, especially how it's described by Kamil Gryzbek. From what I understand, the architecture should easily support pulling a single service out from the monolith and running it as a separate process. Lets say we have this starting point: To then pull out a service, we would hav...
Prolog: I have a domain-layer which contains some entity-classes like Customer. I have a application-layer which contains some data transfer object classes like CustomerDto. My Problem: At a presenter (in my presentation-layer) a use case interactor was called like NewCustomerUseCaseInteractor.Execute(new NewCustomerUs...
Say that I have a REST endpoint for a chess server. If I'm not logged in and do a GET on /games I could get all running games like: { running_games: [ ..... ] } but if I'm logged in I could get a different representation for that same endpoint /games, something like: { your_games: { waiting_your_...
I have a question about the general guidance of how to properly mongodb design: Scenario: I have many collection of objects, all uniquely identified by their contract_address, and i want to be able to pull from there when need be. I found this post, but it didn't seem like enough reasoning. so would it make sense to ha...
Let's say we have a class( My_Func_Dec ) that models a 'function header declaration' as it might appear in a .h file. const std::string func1 ( const std::string& arg1_, const std::string& arg2_ ) const ; As we might guess from the pic(see above), My_Func_Dec initializes its internal data by processing(left-->right) ...
I have some REST API endpoints set up to create a blog post. Each blog Post is owned by a user. I have the following routes: /users [GET, POST]: Get a list of all users, POST to this endpoint to create a new user /users/<id> [GET]: Get info for the specified user /users/<id>/posts [GET]: Get all posts for the specified...
I'm looking for a pre-existing or easy-to-build data structure available in Java, which can do these 2 things efficiently: Fetch all the values stored in the collection quickly. Iterate over the data structure to fetch each key and its value. Right now, I'm using a Pair<List, List>. With this, I can Fetch all values...
SituationI have a Single page web app with REST API. When the user logs in, they receive an authorization token. The token which will expire after some time. When the user tries to make a server request, but the authorization token is already expired, I want the user to be forwarded to the login screen. Current Approac...
I'm trying to develop an ASP.NET MVC-application with an additional Web API. To reduce code-duplication, I'd like to share as much code as possible, but with the possibility to differentiate between the two projects if needed. My plan is to create a Shared Class Library that contains: Entity-classes Service-classes Vi...
This seems like a common scenario that someone must have solved by now! I have a setup where a Company may have a set of Default Roles assigned, and Users of that Company should inherit those roles. User may also have additional roles assigned at the user level, or inherited roles removed at the user level. Both Compa...
In the past, when I've used MVC, my model objects were just dumb data containers. Everywhere I read says that in MVVM, models should contain business logic as well as being a data container. Now that my model objects also contain business logic, how do I use them as data containers? For instance: my models as an access...
I am trying to challenge my understanding of DDD by pushing it to the extreme. My question is not about a specific practical use case. Rather my question is an abstract one related to DDD in general. Therefore, I do not have any source code to share but thoughts to discuss. The domain model should be isolated from any ...
I'm trying to make an application in ASP.NET MVC. I'm using AutoMapper for the conversion between entities and ViewModels. In most cases, this works fine, but when I need to add some additional data (f.e. a list of items for a drop-down list), I'm a bit confused about where I should retrieve this data and populate the ...
Scenario I have a system where a user can upload an Excel file which is validated and then used to provide data for the application. There are two distinct operations I need to handle with this file: Validation: On upload, I want to validate report any problems with the file, so that the user can fix it. Some of the v...
not quite sure how to put that into the title, because the issue is a bit specific. Basically, we're using gitflow (slight variation of it) in our application. So, this means we have the following branches master (PROD) uat (STAGING) dev (TEST/QA) We create all our features from dev. The developer creates a PR for th...
I work with csv files that after some steps provide the initial data, and with a database that is derived from this data. The database then is read from and written to in many different ways by the rest of the application, the csv files are then ignored. Therefore the idea arose to make one data application layer for w...
I am reading a book C++ Software Design by Klaus Iglberger. In the book, the author asserts multiple times that recompilation effects of dependent code is extremely bad. For example, The heart of the problem is the direct dependency of all shape classes and functions on the enumeration. Any change to the enumeration r...
I am looking to architect an application that will run on the local network. What we have is: 'n' number of laptops connected to a local network All those laptops will be running that application If one of the application makes an API call to an external network It has to inform all the other laptops running the a...
There are techniques of proving program correctness under all possible cases, but that is a more advanced topic, for a later subject in your curriculum. I always had this doubt: Is it possible to know all possible defects in a program before I write a single line of code? (i.e., How to detect a bug during the design...
I'm writing comment to a function that gets settings from a json file, I found my Github Copilot suggesting it being not a good idea to do so. I've looked into Why are global variables evil? [closed] and see mixed opinion on "bad" or "evil" depending on the circumstances. In this case, is using global dictionary object...
Context My office is currently working on distributed (micro) services, as part of this we obviously have Service Discovery between these services so that they are aware of each others locations (when they need to be). Possible Issue It has been discussed that we could additionally have what I have coined Object Discov...
I'm looking for an elegant way (a design pattern if such exists, not a library) to map two classes that share the same base class, without duplicating the code that maps the properties of the base class. Let's say I have public abstract class RequestBase { public DateTime BornAt { get; set; } } public class Reques...