instruction
stringlengths
34
36.1k
A lot of articles online give very simple examples on Blue-Green deployments. However, how would data update be handled? Say I have a column called Category with values (A, B, C, D). In my next release I want to consolidate values (B, C) -> (E) to handle a new logic. However something goes wrong and I need to rollback ...
I'm building a news aggregation system that collects news articles from several websites, then classifies them into categories, tags them with keywords and saves them to a database. All actions are activated in the same sequence, begins with news scraping. Everything is put in a loop that runs every 5 minutes. Trying t...
I've been looking at examples of sequence diagrams for observer pattern but most implement push model where the subject updates the observers. In a pull model how would it be different because technically the subject updates the observers still when there is a change just that the observer triggers the data extraction?...
I have to design the architecture of a system that processes messages in a distributed manner. If this were the only requirement, I would use a message queue like Kafka and distribute the work with Faust. This solution would be perfect for my use-case because the work that needs to be done for each message involves a l...
Stack Exchange has some bits of what seems to be session state -- for example, whether you want to see 15, 30, or 50 questions per page when you view a list of questions. You can click on the button at the bottom of the list to change the setting, that value is a URL query parameter, and thereafter the new setting is r...
Important note: This is PHP (5.3+). PHP is stateless and everything you do dies when the request is over unless saved to a persistent storage, but if the answer provided gives me pseudo-code, I'd also be happy. Also, I can't use routing. I need something that deals solely with objects and parts of them. My system right...
I've been asked how to re-design a legacy system by a relative for a company that builds custom chairs. On their website you can customize your chair in about 30 permutations : chair type, material, if wood what kind, color, height, leg type, etc.. They have been working for years with a system that creates a ~40 chara...
I have a standard application and in this case, it is an Accounting ASP Net MVC application. Now, I have a new client that has their own specific requirements like other fields and some custom behavior that doesn’t make sense to be included in the standard application. The most straightforward thing that I could do is ...
I am new to the formal idea of UML diagrams, but I have drawn and read system type diagrams for years. I wish to set a very simple exercise for the analysis stage of a project. I am considering the operation of a checkout till with a built-in scanner and weighing device. I can capture the interaction of the checkout op...
I need to share some associative data between different parts of my application with two requirements: immutability (so read-only) safety against mispelling or unavailable index inside the data mixed type I have no need for behaviour, internal state, validation or other DDD related features, just simple read-only da...
Let's say I have a stacked 2 layer app (High Layer (HL) and Low Layer (LL)) that is implemented in C. HL defines a few #defines. HL calls a LL function with a parameter that takes values of the #define. LL wants to check these values and proceed accordingly. Now my question is what is the best way to share these #defin...
...I wanted to find the source before writing this Q, sadly I couldn't. My mental model was that exceptions were thought as an alternative to returning error codes from a function, which is the C way to signalize failure. Returning error codes and managing them is error-prone, cumbersome and tedious; which is why a mo...
There is often introduced a concept of using metadata in events. I just would like to understand the difference between data (which is referred to as payload) and metadata. I've read what I could find on the web on it, still would like to hear some opinions. Let's take some general case. Say there are some items (Item...
I have a confusion. So, in OAuth2.0 there are 4 types of Grant (Authorization Code, Password, Client Credentials and Implicit). In my use case, I have two login scenario. The first one is using username and password. In this case it's clear that I should use Password grant type to give access and refresh token to the u...
I would like to store the frequencies with which words co-occur with each other over a variety of contexts in a large (> 1 billion tokens) text corpus. I need to store the word pair, the type of co-occurrence (e.g. word1 in the same sentence as word2, word1 in the same paragraph as word2), and some metadata about the t...
With 'global variables', I mean Variables on namespace level Static data members in classes Static variables in functions In a big C++ project I would like to have a mechanism (like a compiler option) to prevent such data in most parts. A compiler error or warning would be nice. Of course, at one point you have to in...
I'm working on a text GUI library which comes with builders for UI components (Buttons, Panels, etc). I have a base class for these builders which I'd like to redesign so that meaningless component states can't be represented with the builder. Right now the API looks like this (over simplified): interface ComponentBuil...
Let's say I have three classes: A, B, and C. All of these classes are simple and they create a cohesive unit. In addition, B depends on C and C depends on A. Most people would put these classes into one directory: java ├── A.java ├── B.java ├── C.java It's simple, but it's difficult to tell where the logic starts. You...
I have seen a project which uses Maven submodules. The project itself is a spring boot application that exposes Restful API endpoints for a microservice ex: Customer Service (getCustomers, createCustomers etc); consisting of standard model classes, repository, service interface&implementations, controllers etc. Is ther...
I created a function to read floats (IEEE 754 binary 32-bit) from strings, for developers. I have everything finished and working perfectly, except i'm wondering if a user/or programmer enters a string such as "NaN" that does not specify QNaN or SNaN, what should it be considered? or should "NaN" be considered an inval...
I have been going back and forth in a discussion about polymorphic enums to call different DAO methods depending on enum entry, and I haven't been able to get a common agreement on this subject. Lets say you have an enum that controls your response style, (short and detailed), and then you override a method to get that...
I am looking for some general architectural guidance about designing good cloud apps, primarily using AWS. For the sake of argument, lets say it's a single page app, written in JS, hitting a couple of services like S3 and maybe some Lambda functions that read/write to a DynamoDB. Option 1 - Make calls directly using A...
We are designing an architecture of a high availability distibuted system and we are considering server side vs client side service discovery. There is one problem, I need to solve - how is it possible to discover the Discovery Service (Eureka/Zookeeper/NGINX...)? Is there any way, how not to hardcode/hardconfigure the...
Consider a web api exposing two kind of resources: Users and Teams with many-to-many relationship, typically a REST api will expose the following trivial endpoints to read data: GET /users GET /users/{id} GET /users/{id}/teams GET /teams GET /teams/{id} GET /teams/{id}/users Now I am trying to design endpoints to mana...
I'm going to share an example where I noticed this and would like to know if there is a known pattern of why one would do this. I have two instances of rsyslog running on different machines. One acts as a receiving server, the other as the sending client. While there is a connection the following is seen on the server:...
As the sole developer in a startup, I had the luxury of being able to make a lot of decisions in the architecture and frameworks of our application. Fast forward 4 years and an acquisition later, I have a team of 5 and a lot of times it feels like the wild west. People making whatever design decision pleases them: int...
For simplicity, let's say I have the following C project structure: src/ utils/ logger.c logger.h main.c secondary_component.c main.c starts with: #include "utils/logger.h" I would like to keep the code and its structure as-is, but stub out logger.c, logger.h and avoid compiling secondary_component.c ...
I'm working on a bare-metal embedded system, with a class that can be compiled for different hardware versions. The class takes in a pointer to a device and uses it, or takes in NULL if the device is not present on that hardware. When the device is not present, I want the device code to be left out of the compiled bina...
I've recently "discovered" the IoC realm, and decided to refactor a project I'm working on to use such a container. To be specific - I'm using autofac in C#, in a .NET Core console application. The program reads some configuration at startup, doesn't really matter how, just that it's all wrapped nicely with interfaces,...
I have a User entity, which may have a RefreshToken (for authentication). Notes: A refresh token doesn't have "identity", but is related to a single user - it is only valid for that user. In the db that means a foreign key to users table. In Entity Framework I can however model it as an "owned" type so that it's part ...
I engineered an ERD diagram using Barker's notation. The problem was to make a database for system of water pipes where one node is connected to another using a section (pipe), each node can have unlimited number of pipes connected, but the pipe must have only two nodes that it's connected to. Each node that is situate...
I have the following method in Java: public method1() { //does something that might throw an exception } And then another method that calls the method above like so: public method2() { method1(); } What is the convention here in regards to try-catch : Should it be in method1() or in method2()?
I've been implementing an authentication flow for an app that I've been making that uses JWTs. When a user is initially logged in or when they register (which immediately logs them in), I provide an access token and a refresh token. Access token expires every t hours but the refresh token never expires. I want to revok...
I have to process biological data input in the format of 96-well plates. explainer for the non-biologists: These plates are basically a 2D matrix of 8 rows x 12 columns of small cups called wells. Each well is used for different assay conditions. During an assay each plate iterates through several assay steps: coating...
I am handling a file with 1 million records and my customer creates this file from his code. I might receive hundreds of these files. I have to read these records and ingest them into a database. It is possible that some of the records might be incorrectly formatted and lead to parse exceptions. What should be the exce...
We're creating a new API to add new Jobs into a legacy system. The question deals with how to handle creating a Job's required parent entities when you don't know the IDs of those parent entities to assign to. The structure of when a Job is created is as such: A Job must be assigned to a Project. A Project must be ass...
I also had a look at How do I deal with side effects in Event Sourcing? but the solution wasn't clear to me. If I store "EmailSent" event in the event stream, I might issue the external request to send the email again, thinking the previous send timed out, moments before the confirmation of the first email being succes...
Let's say I have branch-1 (branched off master (major update)) and branch-2 (also branched off master (minor update)). What is the best approach to do when I need to create another branch, e.g. branch-3 and I need to continue the work from both branches while their PRs are still pending? And what do I do once both the ...
I have been working on a python project for sometime which has been structured in following manner: We have a function like this: def execute_cmd(cmd): (out, err) = subprocess.Popen(cmd).communicate() return (out, err) and this function is used over and over to execute binaries of a third party library. I did...
Suppose I want this on my User entity: user.createNewSecurityToken(); That means: public void createNewSecurityToken() { var buffer = new byte[32]; new RNGCryptoServiceProvider().GetBytes(buffer); // <--- here's the issue this.Token = Convert.ToBase64String(buffer); } This is not a DI dependency, just a class ...
I am currently building a distributed system that consists of two separated nodes, connected over wireless Lan. The processes communicate over a bidirectional TCP Socket and JSON messages. For the application, it is quite crucial that all transmitted messages arrive at the receiver consistent in the correct order. Besi...
I'm designing an API and I ended up having a few pure abstract classes. Because of the nature of the problem that I'm solving, each derived class has to be initialized with different sets of parameters. My solution was to basically define their constructors and pass the appropriate parameters when I'm making each class...
Many projects need a set of various utilities. There is some discussion about where to place them. But what happens if the utility becomes part of the standard? For example, C++ kept adding to the standard many useful functions. For example, std::clamp, or the random number generators. Many projects needed that functio...
For a method whose signature looks like this: public T Add<T>(T first, T second) where T : struct, IEquatable<T>, IComparable<T> which can work with all of the integral types, do I need to write tests for each of those, e.g. public void Test_Add_Int() { Assert.That(Add<int>(10, 20), Is.EqualTo(30)); } public void...
A new feature is being developed. I want to test this feature in different scenarios. We have existing tests that correspond to this scenario (but they test other features). Should I : insert new assertions about the new feature in these existing tests ? create new tests specifically about that new feature (this wou...
I am looking at Versioning Micro Services solutions and got a little carried away with OO design. Using WebAPI, I got to the point where I can use OO design to choose the correct version to run with only a single endpoint. But is it good practice to reduce the endpoints like this? I admire the SOLID-ness/OO-ness of hav...
Current situation I'm developing a test-framework in python for end-to-end tests for a large ERP application. The AUT (application under test = ERP system) is structured in modules and provides a lot of different forms (e.g. to place an order), which need to be tested. The test-framework provides a high level API to ex...
I need some advice regarding repository pattern. Let's assume i have UserBal which stands for business logic which uses UserRepositoryDal where all database logic for that entity stands (queries to table T_Users because my repositories uses stored procedures.) In my database i have table T_Users and T_UserTypes. In T_U...
I am working on a project where clients are able to create objects in a database. Each of these objects has a description string that describes the object. Let's assume we are looking at an object that represents a car: A red car manufactured by BMW with 62000 miles A pickup-truck manufactured by Dodge from 2010 A car...
I have written this function which checks if a user already exists in the application: async function ValidateUserExists(username, email){ if(!username || !email) throw new Error('Invalid number of args passed. Please pass username and email'); let taken_valid_username = null; let taken_valid_email = null;...
I find myself lately implementing the same concept twice, once at a low level and once at a higher level. Let me see if I can explain it... For example, given the notion of a database, I have one interface (say IDatabase) with methods like void AddCompany(Company company); which is what I consider "low level". However...
I'm working on a framework which builds on .net core Identity. Let's say I wanted to extend the IdentityUser<TKey> class with a ParentUserId property while the developer should still be able to decide which type to use for the TKey primary key. This property would be a foreign key to another user, but could be null if ...
I have two tables in a database: A users_table and a items_table. I need a way to be able to define which items each user gets access to. I thought to create a third table containing: 'user_id', 'item_id', and 'has_access' columns. The problem I am having is that the users_table as well as the items_table have 'active'...
Before I ask my question, I want to note that this is not my own code; it comes from the Refactoring Guru website: I often find myself using the code on the left, and I have one primary motivation for doing so: in the code on the right, you are unnecessarily pushing and popping a stack frame for the same operation t...
I'm trying to figure out how to apply composition over inheritance to a system I'm building, and tripping up when I try to apply it to my page objects. The relevant objects are: PageFactory Page Route [Entity]Repository (multiple) The system is pretty straight-forward. The PageFactory is used to build and retrieve Pa...
I'm working on a program that takes in user input which often includes things like math.sqrt(), imaginary numbers, multiplication, division, and similar (basically, standard math plus imaginary numbers). Currently, I'm using eval() (don't worry, this is not the sort of program that is used on public computers and I hav...
In relation to DHT's (distributed hash tables), how do decentralised systems deal with all nodes disconnecting and thus having its routing meta data invalidated? i.e with the implementation of DHT's in torrent clients, what would happen if all nodes (including the root/parent) were to become inactive? Would it mean all...
I've been doing some studying on the types of inheritance. From what I've learned: Single inheritance refers to when a class inherits another class. Multi-level inheritance refers to when a class inherits another class that inherits another class, etc. Hierarchical inheritances refers to when a super-class that has ma...
I have to build an app that manages orders between customers who submit the orders and riders who deliver them. Riders work in shifts, so when a customer submits an order, only the riders that are active in that particular shift should recieve a notification. I chose Firebase as backend for my app, so I'd use cloud fir...
I am creating an MVC inspired PHP framework, mainly for learning purposes. I basically have the framework created and am building an app on it and improving the framework as i go along. I am still confused/not sure about certain aspects of this sort of architecture, and at the moment i am questioning my implementation ...
I have a c# library that sends requests to a number of HTTP endpoints and then tries to de-serialize the result into the specified type. An indicative method is defined as: public virtual async Task<(T, HttpStatusCode)> GetAsync<T>(string resource) The issue I now have is that I would like to return more contextual in...
I am currently learning agile with a focus on project planning. I am having some issues aligning the teachings to the real world. With agile I have learned, that we need to get customer feedback in every iteration, and we should include this customer feedback into our backlog so it is address, and we give the customer ...
I've noted that fibonacci sequence is quite popular in planning poker, but is it a reason for that particular sequence? Wouldn't for example powers of 2 work equally well? Both sequences are more or less exponential while fibonacci uses a factor of the golden ratio (approximately 1.6) so fibonacci has somewhat higher r...
Context I am currently working on a user management applications (UMA) that manages a data warehouse security management (users, rights etc.). The data warehouse has production databases (and production users) + pre-production (PP) databases (and PP users). UMA like any other applications has its own PP and Prod enviro...
I have written a turn based game (Dominoes) using Scala and Akka actors, where a Server manage all the game state and the clients (Players) receive the new state every time one of them plays a card. I would like to implement a web version for this but I am having hard time figuring out if this kind of schema needs or ...
I have to write server (.net core) that is going to read data from 30 different remote APIs. I suppose to run some sort of decision trees, if I find something in one API goes to another API, else some other and so on. Goes something like that: if apiA.response.data has 'some info' { //read apiB if apiB.response.dat...
Say we consider two inherently coupled elements, using a real-life like example: Body PhysicalIllness Note: the following code is pseudo-Java for the sole purpose of syntax-coloring, pure syntax doesn't really matter here. Body is a class that holds several basic properties, such as stamina, focus, etc., plus an arra...
C# web scaffolding has an async call for every member. Why? For example: Async for a login call makes no sense. User has to wait for validation. What else would the app do until the application validated the user. Thoughts?
In my experience, it is often said that in event sourcing "an event must belong to one aggregate" and also "an aggregate is your biggest transactional boundary". Why is this? What harm would come of events like this: { type: "BoblesSent" aggregates: [1, 2], from: 1, to: 2, amount: 420 } Seems like it could b...
I am mainly concerned about how to create concrete objects properly when implementing different interfaces. I have a resource whose variants can support different interfaces. For example, say I have two types of cards, C1 and C2. C1 supports blocking and unblocking of cards. C2 does not support that but the rest of the...
I have two panels, one for the admins and the other for partners. And there are two OrderController with Admin\OrderController and Partner\OrderController namespaces. They both look very similar. What is the best way to avoid duplicate code in two controllers. They have two parts, the first part in authorising and vali...
Let's say I have a database with a table called "invoices". Then I have a web application where users can manually create invoices against said table. I also have a desktop application that can create invoices programatically. I may have other software modules that can all create invoices. To manage the operations agai...
I have an application in C# where several users access it. Each user will have a serial key associated with his username in a table users in a local MySQL database. Example of the table users: User 1: Alan Serial Key: AAA-AAA-AAA User 2: Bart Serial Key: BBB-BBB-BBB User 3: Mark Serial Key: CCC-CCC-CCC These keys ar...
Why does C# make you put in a dispatcher for a different thread to update the UI? Example: Dispatcher.Invoke(() = { lblerrorName.Content = ""; }); It always gives the 'running on different thread' exception, but if it knows I want to change a label which is on the UI thread, why isn't it automatic and behind the s...
We have several systems that hold the same data in different databases. The requirement is to keep the data synced in as much reliable way as possible. Performance isn't a concern because we don't have lots of users. Currently, we're using RabbitMQ to produce events on data changes so that consumers are able to track t...
I have to map a legacy database with tables that have a lot of fields and relations. For example (simplified code), @Entity @Table(name = "VISIT") public class VisitEntity { @Id private Integer Id; @ManyToOne @JoinColumn(name = "CD_COMPANY") private CompanyEntity company; @ManyToOne @JoinColumn(...
I am looking to construct a program that takes, as input, 576 [x, y, z] points as well as 576 corresponding distance values. I want to find the [x, y, z, radius] parameters of a sphere such that the distance from each of the input points to the surface of the sphere matches as closely as possible to the corresponding ...
Note this question is about when there are multiple relationship types. This is not the same as this question, where there is only a single member relationship. Say we have persons and organizations. There are two types of relationships between them. One is employment and the other is customer. I'd like to be able to...
I've been reading recently about Event First approach to microservices where Event Store is a Single Source of Truth for all the applications (https://dzone.com/articles/data-consistency-in-microservices-architecture). This is very different from Change First approach were we: Save item to microservice database (in t...
Given that when is supported in try...catch blocks, does it make sense to create a single CustomApplicationException class, say, with an enum ApplicationExceptionReason Reason property to differentiate "reasons" instead of creating a new exception type for each reason (it could have Flags, if multiple reasons are neces...
In writing a split function that breaks up a sentence into each individual word based upon punctuation i.e. splits on something like the character class [\s,.?!]+, though for the purposes of this question the implementation is not important, and the list of characters to split on should be considered to be of arbitrary...
For me, I prefer having all my variables, not as pointers. Is it ok to keep all heap-allocated variables dereferenced? For example: #include "Foo.hpp" #include "Bar.hpp" class Foo { private: Bar* ptr = new Bar(); }; Would it be ok to have Bar as a dereferenced pointer, without causing any issues? Example: Bar b = *(...
I'm using StackExchange.Redis library, it seems perfect. Hard-coded events related BankAccount with ID 1: // UNSORTED COLLECTION public static List<Event> DomainEvents = new List<Event>() { new Event() { Data = @"{ 'Operation': 'WithdrawalPerformed', 'Amount': '10', 'UtcDateTime': '05/18/2019 18:47:41.084' ...
Suppose I have an API function which returns a pointer to some memory, that is later to be consumed in an array-like manner. Suppose also that its size is known in advance, and that it's declared like so: returntype API(void); Is it better for the function's return type to be declared as pointer to an array, like so:...
I have a datastructure that involves rating items, much like Netflix do. Now those ratings are numbers that are attached to relations between objects in a graph database. However, it seems as if attaching properties to relations, not nodes, in UML seems to be a difficult thing to find to do. To elucidate. Object A rat...
I've a service called Claims-Service which has following signature: IClaimsService { EnsureClaim(claimType, userId) } It queries database to see if the claim is present in any of my roles or not. Based on my current requirements, I don't have a scenario which requires a user to have more than one claim to do something,...
I am reading a github project: you see there is a directory(debian) in there, what the function of it? I have browsed the directory, there seems have some configuration files: shadowsocks/debian/config.json { "server":"my_server_ip", "server_port":8388, "local_address": "127.0.0.1", "local_port":1080...
I am trying to build a RESTful API (using Flask) that will be later consumed by a mobile application. I also have a requirement to build a Web Admin. The Web Admin will have functionality that will not be available for the mobile client. The mobile client and Web Admin will also share the same database. I have a limi...
I am creating an API that will expose a list of metrics data. Each metric data will contain the following: metricName lowerThreshold upperThreshold The defined thresholds here are what will determine whether the current value of the metric is good or bad. The behavior of the application will be based on how the curre...
I've seen a few similar questions but nothing to address this exact issue... I'd like to have a mobile app that allows users to input username/password once and then be automatically logged in with said credentials on different websites (Moodle, Outlook, MSDNAA and some others that use the same data) whenever they want...
I'm improving/expanding a somewhat large code base, and I've introduced multithreading into it. But with the possibility of introducing code that could deadlock, which is nigh impossible to test for with black box testing alone, I want to at least get some reassurance my code is correct. I've already adhered to best ...
Currently we have a POS (point of sale) application that should call a remote service to declare each new sale. Considering that the remote service could be not reachable we have also a local db at the POS . Actually , there are multiple reason for which a sale culd not be declared on the remote service : We are not...
There are multiple types of appointments, each with their own length. The goal is to find 'optimal' placements for a given appointment type on a given day - optimal meaning leaving as little 'wasted time' (small gaps) as possible. What is and what isn't 'wasted time' should ideally be evaluated based on the lengths of ...
Suppose for example, there could be multiple types of vehicles. And in this scenario, only the speed and how many people can seat in the vehicle matters. Would it be better to have a concrete class, with vehicle type as an Enum, or should there be an vehicle interface and different types of vehicle implementing this in...
In our team, we are using AWS as our main cloud provider and currently, we have 3 projects hosted on their platform. We are about to have 2 more projects in the next weeks, but first, we want to organize our projects, because our current organization is a little bit disordered. We want our projects to be organized fol...
I am making an application in which there are 3 tables. A user can click a button to request to move an item from table 1 to table 2. Essentially, this means that an item is deleted from table 1 and an item is posted to table 2. However, I assume it would be worse performance to make 2 http requests since I could techn...
Part of our project includes an open source GO server that we have open sourced for transparency. How can we prove that we havent made any alterations to the code before we deployed it?
I am new to functional programming and I can't find a function like reduce to build an AgreggateRoot given an EventStream: List.reduce ((aggregate, event) -> aggregate) eventList As I understand the reduce function only works with parameters of the same type of the output
I'm new to the application architecture world. I walked through Docker's sample voting app, and see that basically everything that can be made into a modular piece, is made into one. I'd really like to work through an example and feel that I've come up with a reasonable solution. Please correct everything in the nit-p...
I think this question is simple, but I'm not often designing APIs and so I haven't confronted it: How far should we go to adhere to the single responsibility principle? Let's say we are implementing an RESTful CRUD API composed of microservices. For the creation action, we need to significantly restructure incoming dat...