instruction
stringlengths
34
36.1k
I have a Task in my project , to complete that i have call(REST) multiple external systems. If my call fails at some level , i have to rollback all my previous calls(making call with undo action) . Looking for effective way of implementing it in JAVA. Can Someone point me to any design pattern if exists? public v...
Suppose you have a bounded context with ~30 business events and, for simplicity sake, the same number of commands like ChangeUserEmailCommand -> UserEmailChangedEvent initiated from a web UI. Processing a command may fail for the following main reasons (besides infrastructure failures of course): Validation issue (ema...
I'm interested in starting coding dojos at the company I work at (during or after working hours). I think it will help to spread knowledge on how to write clean, concise and consistent code. I've been part of coding dojos in the past and it's really helped me be a better software engineer. I especially think that this ...
I have an api server that relies on an auth server (both owned by the same company). Once the client gets a grant from the auth server, it is no longer needed, because the only information I need from the auth server is the user profile. Should I in this case cache the user profile on the api server, along with the acc...
I'm a programming teacher. My students learn structured and then object oriented programming in JavaScript and C#. They learn SQL, MS SQL Server, Dapper and EntityFramework Core. After this they make applications with data access code directly in the ASP.NET Core WebAPI controllers. I tell them not to do that, and tea...
I am new to design patterns and working my way through the Factory Method and Strategy patterns. I understand that Factory is a creational pattern and Strategy is behavioral but I struggle to understand when to use which one. For example, I have the following classes that updates client details based on the company spe...
I think I am just look for a bit of code review advice. It might possibly be a methodology question? Essentially when I am pulling data (usually from a REST request), I generate a service, then inject HTTPclient of Angular common so I can use a simple GET to grab the data. Like below: interface ReportContact{ Email: ...
Reading the blue book at page 152, we can find this: [A repository] provide methods to add and remove objects, which will encapsulate the actual insertion or removal of data in the data store. Provide methods that select objects based on some criteria and return fully instantiated objects or collections of objec...
When talking about scaling a system, it's often said that vertical scaling has limitations. So after a point, we need to scale the system horizontally. What are the limitations of: Main memory - What is the maximum amount of memory supported by a 32bit and 64bit processor and why? Is it the width of the address bus an...
I'm struggling to fully understand MVC pattern, I found a lot of information on the web but they are really confusing because it seems there are various ways to do it. What I understood is that the user interact with the view which will call a method of the controller which will modify the model. The model notifies the...
I have an API whose job is to aggregate resources obtained by calling multiple other APIs and then give out the aggregated response to the client. Currently even if one or more dependent API calls fail, I go ahead and aggregate response from the other dependent APIs and then give them out to the client with a 2xx statu...
Is there a pattern or design that I could refer to for dealing with bulk data in inter-services communication. My use case is to import data from upstream feed files(say 50k records) to our distributed system. So those records would end up in multiple services. Each record represents an instance of an entity in our sys...
I would like to create a state machine. Each State would have its run method, and, according to some logic would then set a next state. Option 1: If each state is responsible for determining a next state, then it would have a next_state() which would return a pointer or an id of some other state, thus forcing each s...
I have problems to write my first simple pseudocode. The input of the algorithm is an ontology which contains axioms and an inference set, exactly an inference is defined as an object with set of premises and an conclusion. The output of the algorithm should be the set of conclusion that we can derive from the given ...
So I am trying to design a simple URL shortener application where every time a URL is queried, it is going to update the number of times it has been queried. I'm thinking of using MongoDB and I am thinking of some sample schema like this { id : ...., //Mongo-generated ID originalUrl: .... // The original URL shortUrlKe...
If we have a long list of JSON entries, we could put those on an HTTP body so we could parse the whole body of JSON with something like JSON.parse(): HTTP/1.1 200 OK Date: Sun, 10 Oct 2010 23:26:07 GMT Server: Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g Last-Modified: Sun, 26 Sep 2010 22:04:35 GMT ETag: "45b6-83...
I've designed my app so it stores the data of each sale in the following way: each order contains different products so for each product in an order a table stores the quantity(of the product) , net sale and earnings. I will need earnings and net sales of days and months for display, so my approach would be to sum the ...
I'm pretty experienced with developing both frontend as well as backend applications, with a variety of programming languages and frameworks. I know the problem space and concepts involved in both quite well. Still I find my thinking around the differences in application architecture and also the differences of the com...
I'm using some modified MIT licensed code directly in my project and am concerned about how to correctly attribute it. The code in question does not have license text in each file, only a single LICENSE file at top level. I have included the contents of that file in my own licenses file. In this file I also have the li...
Disclaimer: I don't expect zero tech debt. In this post, technical debt problem refers to severity that has been causing negative impact, say productivity. Recently I was thinking to build a tool to automatically generate tech debt report from issue tracker - introduction rate vs cleanup rate over the time. Apart from ...
Sorry for the bad title. Couldn't really think of a good name without an explanation. In our system (source is inside Oracle PL/SQL packages) we have quite a lot large SQL queries with a sh..load of variables, dozens of joins to multiple tables and a lot of conditions. Some of those tables and variables are even config...
Let me try to summarize a bit more with a simple example: You're building a large application, a user portal for example, with feeds, news, account management, and a whole range of difference features. During development it's decided you need to implement mocked data, for either ease of testing, or perhaps because the ...
I'm developing GUI for controlling and testing hardware device. The GUI consists of many basic controls like textboxes and radio buttons which are mostly independent of each other - each control sends a command to device to read or write a parameter. And a couple of timer-based monitors querying the device for status e...
There is a feature that is now deprecated and going to be removed. Adding a logging statement, observed by some alerting mechanism, can help finding out whether the feature is still being actively used and upgrade the clients that do so. Although not necessarily technically important for the diagnosis, I wonder what wo...
I've learned many ways to keep a domain model flexible over the years, but there is a remaining case where the setup resists change. Suppose that we have kept our domain model properly isolated: we can change it easily. Now a change requires a fundamental restructuring of the domain model. There is one thing in our way...
Are there other general purpose programming languages besides Objective-C +ARC and Swift which target the llvm and use static compile time Automatic Reference Counting for memory management?
I have a project in which one module keeps the state of the target device (things like current command level, but mostly status registers caches). I'm aware that having a global public variable (Singleton pattern) is considered a very bad practice, and I understand why. Instead, my approach is to use an opaque pointer ...
Suppose I have in my domain model two aggregates: Dog and Cat. Dog is composed of DogName and DogFood. Cat is composed of CatName and CatFood. The repositories, however, are a PetNames API which only provides a single endpoint to retrieve all names, and PetFoods API which only provides a single endpoint to retrieve a...
An example to show what I mean exploring a deeply nested object structure. This is a real code I deal with today (it is vue but that is irrelevant to my question) data() { return { customer: {}, settings: [], task: {}, ... } } I read the code several times to find out the c...
wasted requests not enough time for those requests | | | | (1) |-x--x-----------------x----x--x--x| x x (executing requests) .. . ..... (sending requests) (2) |-x--x-----------------x----xxx...
The question is about my database design. Is it OK? I feel uncomfortable about having 2 separate WordTraining and SyllableTraining tables and about too simple design (not much normalized). Maybe there are any other issues. My web-app teaches kids to read syllables and words. First the user (kid) chooses - whether to t...
We have daily 200-300 live projects which receive online traffic from our vendors across all our live projects. We store this data in two different DB (I know this sounds bad, but seemed good at the time of designing for various reason): project information in - projects table of MySQL traffic data for those project...
For context, I'm writing TypeScript, but I believe the concept works for many languages. I have a function getFooParams(): FoodParams, that gets data that gets passed to foo later on. (It's a React-Native project that has some limitations on how the data can be passed to the native code, so this architecture seems unav...
Suppose I initialize a library, say, in python object - #filename: file_A import file_ class A(): def __init__(self): self.pd = file_.pd self.np = file_.np And suppose the content of the file_ is, #filename: file_ import pandas as pd import numpy as np You might be wondering what's the sense of i...
Brief description of a problem - providing factories which are creating same object type in different ways and following rules of DDD (isolated domain model, independent domain objects inside of it). I have some domain objects in my program and couple of functionally different blocks which are satisfying some needs of ...
This question is regarding the better architecture to follow for API Development in Java using any RDBMS database backend. Currently, we are using the below approach to fetch data from database and passing it to the client. Here, Once the request is made to the rest controller (e.g. Spring Boot/Java EE), it makes a dat...
A programmer keeps making cosmetic changes to the code while we have a strict deadline and the contract stipulate "no changes to the existing code". I am wondering where this "attitude" comes from: DevOps ? Agile ? Changes performed: Replacing explicit variables with "var" Renaming short variable names with longer on...
I understand the rationale of avoiding using namespace std - this defines too many casual names the developer may not be even aware of. I tried to work around the problem with the help of using construct. Most often, I it was using std::string and using std::vector, because these are really very common cases and writin...
I use XAMPP to host an Apache web server and a MySQL database. Most of the data processing is done on the user's mobile phone. After a certain activity, information of the user is sent to the web server. The PHP script checks if the data is already in the database, if it is, the data is sent to the Firebase Cloud Messa...
I'm working on a parser for a (very small) toy language, and I want to test that it's parsing expressions with the appropriate precedence. Previously I just had arithmetic operators, so there weren't many possible combinations of operations; however, now I'm adding logical/relational operations, which means there are m...
I was planing to create an API based on microservices, I'm stuck on how to solve a specific scenario. Initial plan is, all microservices are only accessible through a REST API. Based on the next schema, if you want to get all the orders you simply go to /orders and get a list of them. But whats happens when you want to...
I'm processing data and writing in a database, that is used by my colleague, a designer, working on data viz. How can I efficiently, say, add a new column for my colleague to use in their visualization? I have a "production" output which they uses, and a "staging" output that I use to check my result, they also have a ...
State of the union: C# Events/Eventhandlers are: blocking throwing Exceptions sequential deterministic executed in order MulticastDelegates a handler is always dependent on the behavior of the handlers registered earlier Actually they are pretty close to regular function pointers. Despite beeing a sequence of them. I...
This is the case: Clients want to know how much time will be needed to finish a particular task (not the group of tasks). They are asking for man/days absolute estimation and only when they get it, they decide whether to approve or not. Teams are trying to avoid giving absolute estimations and to focus on relative es...
I have a medium-sized Angular-based web application that I'm currently implementing some permission components for. Overall, the areas where the permissions components will be used are virtually identical, but the specific endpoints (and the parameters that need to be provided to build those endpoints) are slightly dif...
After visit dozens of pages searching a "non-sockets-or-iphone-conceptual-example" of Adapter Pattern, I have found this one: Lloyds bank is an international bank offers services worldwide. For offshore account holders, the tax rate is 0.03%. And, in India it offers two types of accounts, Standard and Platinum. ...
I hope I'm directing this very general question to the right audience. If not, don't hesitate to redirect me elsewhere is possible. I'm part of an initiative at a large company that is starting its journey towards open business APIs to offer data and new digital services. Our team has examined loads of existing APIs ou...
I am currently researching approaches for moving our application to Docker containers and stumbled upon a question to which I could not find a clear answer. Our application has several separate databases that are currently hosted in one database server. When moving to Docker should we keep the architecture similar (i.e...
I am making a data visualization application in Unity game engine that simply shows data in a 3D environment using google maps API. I am using the three-tier architecture to explain the application. It has the following layers Presentation Layer Shows the visualization Logic Layer Transforms the data as per logic from...
I'm developing a real-time fraud detection system for a bank. The job of this fraud detection system is to decide whether the incoming transaction is fraud or not. The system has no interaction with the banking customer. The fraud detection system has use cases like capture incoming transaction data, calculate the risk...
Why did c++11 add a separate find_if() instead of simply overloading the existing find()? Wouldn't overloading the function be sufficient?
Note this is a general, conceptual question about performance optimization. motivated by the following real-world case. I have a file on a Windows network drive that has a 100Mbps limt; it is a binary file and is 165MB. My local machine has software on it specifically designed to manipulate this file format, and when...
Hexagonal Architecture seems to make so much sense when I read about it (like more than I can say; the ultimate eureka moment), but actually implementing it is a different story. I more or less understand the structure, but my biggest problem I think is the delineation between components. In the simplest example, say w...
Well as per title, does it matter in any way functionally (say when rewriting history or something), from which branch one derives a new branch? If at the point of time when creating the new branch all existing (or all relevant) branches have been merged together so they point to the same code? To explain how this "cou...
Versioning is always a big question and I see many similar questions here, however none really answer my question so I try to highlight the things that are important to me specifically. We have a single repository for a multi-module maven project. The decision for a single repository was made, because the modules are (...
In a web app i'm working on, there's some i18n/l10n support. Some entities (I'm using locations as an example) support having names in multiple locales. The app has a primary_locale (defaulting to 'en' if unspecified) as well as an other_locales setting. Besides that, each user also has a locale setting (again defaulti...
How specific is hardware optimization when building from source and what should I look for in the documentation to decide if building for my hardware might be worth it? From threads like this one I gather that optimization for my "CPU and environment" is a possible advantage, but that there are also risks. How does on...
As a learning exercise I want to develop a system using microservices. I have designed my authentication/authorization architecture and would like to know if there are drawbacks to my design. It is as follows: Authentication service has following tasks: Issue JWT signed with RSA key that does not expire Gateway tha...
Say, you pre-validate if a username already exist in a registration form in the application layer. E.g., You send back a nice "username already exist" error message to the user. While unlikely, there's still a possibility that two different users can "simultaneously" pass the application layer validator and one of them...
Searching for a good PHP real world example, I've found this example of "composite" using: FormElement as Component Fieldset and Form as Containers Input as Leaf (this is my UML from the code): So, Is this form generator a valid Composite GoF?
When would I use reactive programming libraries like RX Java and Project Reactor compared to stream processing engines such as Storm and Flink? I am aware that these concepts might not be directly comparable, but I would like to understand the relationship between both concepts better. My current undertanding is that ...
Context We have an application that is written in .NET and runs on a Citrix server. This app consists of shortcuts to external tools (like: DameWare, VNC viewer, mtsc.exe, msra.nexe, ...) that are installed on the server. The user fills in a hostname in the app and the external tool is started after clicking its button...
I'm currently designing my first API and I had a question: Should an API return all information about an object and its foreign keys? To explain the above a bit better, this is a part of the database I have made: When I get a single event and I know that the person making the request needs the information about Event...
I have the following code: const string endPoint = @"foo{0}?pageNum={1}&itemsPerPage={2}"; const int itemsPerPage = xxx; InvoiceCollection response = await _apiClient .GetAsync<InvoiceCollection>(string.Format(endPoint, _apiClient.OrgId, 1, itemsPerPage)); if (response?.TotalCount > itemsPerPage) { var allInvo...
I have a question about best-practices in terms of reliability. There is some data residing in RAM of some process and the data needs to be delivered in a bunch of external storage providing the least possibility for data loss. The data are not required to be read again by the process. I currently think that the way t...
Imagine a twitter-like app where users are allowed to follow to a limited amount of users; say 100. I have this code: fun follow(followerId: String, followedId: String) { if (repo.countFollowing(followerId) >= 100) { throw MaxFollowingReached() } repo.insertFollowingRelationship(followerId, followedId) } And...
In programming terms, what defines Open Source? I am building a platform that I want to be open, to be used by other programmers in the context of running their own apps on it at the same time for companies on their public cloud. The only restriction I want to have is if anyone, including companies, wants to make a p...
When evaluating code performance, CPU instructions is not the best metric, since the exact number of operations depends on the compiler, CPU model, architecture and so on. And we came up with a bunch of mathematical tools to describe the performance of an algorithm (the most popular being big-Oh notation) and we simply...
I have been studying Clean Architecture (CA) by Robert C. Martin and have found it quite useful in promoting architectural standards for large applications. Through implementation of a case study, I have a bit of experience of how it can help build applications that are more flexible, robust and scalable. Finally I hav...
I have a proxy server that waits for another server to come online. A client sends a request to the proxy server - is there a way for the proxy server to send a preliminary response to the client to let the client know it has to wait for the other server to come online? Maybe a header that the browser can display? For ...
Software libraries targetting resource constrained environments like embedded systems use conditional compilation to allow consumers to shave space by removing unused features from the final binaries distributed in production. What are the tradeoffs to building a unique binary? Surely there are the obvious space saving...
I am trying to figure out the right project structure for C++ and I am working on Ubuntu using CMake. I mostly work on AI/ Robotics/ Data Science. Assume that I want to generate executables and libraries. I have looked at a few links including link1, link2, link3. I am also looking at OpenCV git repo to gain more under...
In a C# application, I've got a behaviour that I would like to be available in different classes that not necessarily share the same ancestor. What better opportunity to 'favour composition over inheritance?" In this case not only composition is a better way, but can also be the only way. Unfortunately, the code is t...
I'm currently developing a REST API which is supposed to be consumed by my App and desktop website. The user should not need to login every single time. Currently I implemented the following: First call to auth with username&password -> master token is returned (valid for 1 month) and stored in the DB. On client side,...
We have a service where we have billions of key-value data stored in some storage. Before actually querying the data, we query the bloom filter to determine if the key may exist or definitely does not exist in the underlying store. But the problem is with ~ 1 Billion keys and 0.1% false positive rate, the size of the ...
I have the class AircraftManager that keeps track of a list of Aircraft objects and a list of AircraftListener objects. A DataSource (custom class, not sql related) object retrieves information from an external source, the data sources decodes the message and calls appropriate logic on the aircraft, i.e setAltitude, s...
Based on what I have been reading about the Liskov Substitution Principle, I understand that a square and rectangle class cannot be a part of the same inheritance tree. I would like to apply these ideas to a Folder and a File, as they commonly exist on disk. Is there a property of one or the other or both which would f...
The title says it all. How would I, in theory, create a binding for different GUI toolkits for a programming language that has no GUI bindings. I ask because I want to experiment with this sometime in the future.
Software libraries targetting resource constrained environments like embedded systems use conditional compilation to allow consumers to shave space and thus increase performance by removing unused features from the final binaries distributed in production. Assume that library developers produced the compiler flags and ...
In a simple web architecture using Spring and Maven where it consists of following layers: Controller Service Repository Shared Where in shared module all the classes that are used among different layers are kept. When creating a flat Maven structure, should we add the Shared module as a dependency to Repository or...
So I learned that the feature I am interested in is called a "displacement map". This makes it so you can take a blank t-shirt (with all it's curves and subtle textures), and apply an image to it so it looks like the t-shirt actually has that image on it. The part I'm wondering about is how do you make this a dynamic p...
We are designing a system, in which we need to store amount of SalesTax applied as well as Tax percentage value. We decided that we will keep tax value in separate table (simplified example): Taxes table: +----+---------+---------------+------------+------------+ | Id | Area | TaxPercentage | StartDate | EndDate ...
For example our App have Access Groups feature which may be enabled/disabled for the User. So we would have multiple checking for feature status in different layers like: if ($user->access_groups_enabled) {...} This may be in all kinds of App layers, f.e. checking is needed for sql queries logic (if AG disabled then s...
Sometimes a class A can have an "associated" class B such that the implementation of B depends on the implementation of A. For example, this can happen when B's objects are to be created by A's objects and are to be "linked" to their creator object. An example from Python: dictionary view objects are created by certain...
I'm thinking about "simple" problem. I have database with messages and email adresses to send: emailAddress string message string Sent bool Is it possible to write a system in which I can be sure whatever happens that email will be sent only once? I don't care if it was received, lets assume that email send operation...
I am designing a MVP for a simple gamification system for a trampoline park(s). External company is providing bracelets for customers, then collecting this data in their own web app, where they extract things like "time in air", "number of jumps" etc. in real time from accelerometer readings (x,y,z) I need to receive t...
I have a git repository and I would like to add the installation steps required to make the project work locally. The project is a company and private project and users will also be contributors. I'm using GitLab. But I don't know in what file to write these steps. I have several options in mind such as: the README.md...
First bounded context: Requisites Here we store user's organization requisites (Title, Logo, ID numbers, Bank requisites) Second bounded context: Bank Integration Here we have all use cases that somehow connected with integrations with user's banks. Use case 1: User adds new bank account requisites from UI. RequisitesA...
I'm building a multi-tenant system that consists of one (SPA) client, calling multiple API's, all under my control. User authentication is done with OpenID Connect, I'm sending an ID and access token to the client, the client uses the access token to call the API's. At this stage, the API's know they receive a request ...
According to my understanding, in the MVC design the Model can only receive the functions calls from the Controller and not from the View directly. Is it true that the Model can change or access the View directly?
I need to set up newsletter signup for a site. Initially, I was eyeing services like MailChimp and SendPulse, but I'm not comfortable with their prices and I'm not really keen on sort of giving up control over and giving them access to the mailing list (for both mine and my users' sake). The downside of not picking suc...
I have a repository function on my repository layer. I use sequelize as data access. I will write tests for my function. Here is the logic I want in English: My function should save a user to database by using the email and password My function should return an object representation of my created user. For the logic ...
I'm modeling the "Domain" Layer of "Clean Architecture" for an application that gets its data from an XML file when starts. The XML file looks like: <?xml version="1.0" encoding="UTF-8" ?> <BluePrint> <BluePrintVersion>1.0</BluePrintVersion> <BluePrintMaxMetaData>500</BluePrintMaxMetaData> <ZoneData> ...
Why is it that some abstract methods in interface hierarchies are redeclared as abstract further down? iterator() for example, abstract in Collection is redeclared in Set and List, and again further down the Set hierarchy in NavigableSet. I'd like to understand why this is done from a design point of view, or if there'...
I was given an API document that contained this diagram. And I was amazed at how cleanly it presents the flow of data between multiple endpoints by putting the end points in vertical silos. Data event flow moves from top to bottom, going back and forth across the diagram. Is there a name for this kind of diagram in pa...
Say, our team owns 3 services, one is responsible for creating persons, other is responsible for creating buildings, and 3rd one is responsible for creating jobs. Also, we have one website, which is connected to all these services. Now, we want to add a functionality on our UI that would take a CSV with fields asking v...
Doing a code review, I ran into this assertion in a unit test: assertThatThrownBy(() -> shoppingCartService.payForCart(command)) .isInstanceOfSatisfying(PaymentException.class, exception -> assertThat(exception.getMessage()).isEqualTo( "Cannot pay for ids [" + item.getId() +"], status is not WAITING")); I...
I'm planning to setup a hybrid encryption procedure in my app. So basically i did encryption for data send from client to server using this method, now i'm confused on how to encrypt data send from server to client. So what i have done so for is that : I generated a public-private key pair using an asymmetric encryptio...
I want some advice regarding my architecture and hosting options. I'm attempting to build an e-commerce site for e-books. It will use nestJS for the backend and ReactJS+Typescript for the frontend. Postgresql will be the DB. I want to use Elasticsearch to provide search capabilities. Initially, I thought to host each o...
I have just been confirmed for an interview and one of the hint questions given by the recruiter was: "Explain Idempotency and a case when you can't make processing idempotent" I understand Idempotency but cannot figure out when it can't be used.