instruction stringlengths 34 36.1k |
|---|
Is it a bad practice (or maybe anti-pattern) to have service to service dependency in the layered architecture? I've noticed that when an application is designed in a way that a service can call another service that carries the business logic it becomes very complicated and quite challenging to extend an enterprise app... |
We have an application which contains of multiple composer packages.
A default structure of the site is:
src/
application/
vendor/
vendorname/
framework/
filemanagement/
...
Each package has its own version, f.e. framework is running on v1.5.8 and filemanagement is running on v2.3.8.
To improve our code qual... |
Given a layered architecture consisting of
presentation layer
business logic layer
data (access) layer
and a SPA web application communicating through REST endpoints with the backend (eg Angular and Spring), what would the presentation layer in such an application consist of? Would it only contain the stuff related t... |
I have been studying the best practices for a code review, and I was wondering what to do in the following scenario:
During a code review, I see potential improvements, but decide that they are outside of the scope of the pull request (PR). Should I ask the reviewee to do the refactor in that same PR, or should I defer... |
For simplicity, assume my application logs only dictionaries. I want to add a step to Python logging for my application to prevent logging any dictionary with the key password, i.e.,
def clean_log(blob):
if 'password' in blob:
blob['password'] = 'REDACTED'
return blob
One thing I could do is put cl... |
I am encountering a design problem on a new project. I have chosen the library Luxon (https://moment.github.io/luxon/) because I think it suits this project perfectly. Date-fns (https://date-fns.org/) is also great but suffers from very bad timezone support.
Now, I am also using a datepicker library called react-datepi... |
We are developing a mobile app where consumers (companies) create AR content for their products.
The content ranges from simple pictures to gifs and embedded videos. We already released versions before but now some devices (especially older devices) crash due to out of memory errors.
It is worth noting that Videos are ... |
I am developing a RESTful application with nodejs in the backend with express.js as middleware. I am also developing a client in Reactjs.
I want to use an external authentication service (LDAP/AD/ADFS) to authenticate the user to the data supplied by the API.
What I don't understand is how the authentication flow is su... |
Suppose we have some microservices and a saga will run to do a transaction in 6 microservices.
What if the whole system dies(unexpected shutdown), on middle of saga process in the step number 4?(System died, So state is lost)
|
I have a bunch of excel files(Multiple sheets) with some data of similar types, but i'm having troubles when this data has to be inserted in SQL DB. the data in these files are unordered (eg: the table header names are different,the columns are in unspecific order, the orientation of data is different, etc ). The excel... |
I'm building HTTP API with DDD principles. The end goal is that the server runs on some chosen language X but the clients can use what ever language the software supports. Service has state, but HTTP is stateless.
First without language:
storage = new MyStorage(params) // Can be anything from FS based to SQL, etc
servi... |
Example Application
I will try to explain my problem by using a familiar application.
Lets'say I'm building a Discord / Slack / Microsoft Teams clone; and for simplicity’s sake, it will contain 2 services:
User service:
Must sign in to use the application
Once signed in, he/she can either join a group or create a gr... |
I work in a field where lots of code is written, but hardly ever tested. This is because we are foremost scientists who try to solve problems with code. The few coding courses we had, focused on the basics and many have never heard of git, unit testing, clean code after graduating. Many haven't even heard of those duri... |
I'm working with the Dependency Injection Pattern in Unity3D (an engine which uses MonoBehavior, a class that doesn't have a constructor, as the base class for all of its game components), and I ended up building my own solution for it. I don't think that, aside from having to write some boilerplate, it's an anti patte... |
I have a frontend through which users can submit analysis requests, which are inserted into a database. These analysis requests are received in a NodeJS server using Postgres notify/listen. Using Redis and a queueing solution like Bee or Bull, these analysis requests are queued. A typical analysis process is long and t... |
C++ supports protected inheritance: A class can derive from a base class B in a way that the "outside" world doesn't see that class "as a B" but the class itself and it's derived classes does see itself "as a B".
struct B {};
struct Klass : protected B {
// here I am B
};
struct Derived : public Klass {
// here I a... |
I am writing CLI program that can accept very long strings. For this reason I decided to pipe the data into the program as I would hit limitation of the shell / OS.
How should these CLI program display documentation? When I launch it, it waits for input so I have no way of displaying to the user what should be done.
I... |
I'm doing some research on how to scale our current SQL database and need some advice with a possible solution. The goal being able to handle more data and doing it in a way that performs well.
We have one MSSQL database that's a couple TB in size, several hundred tables, some with billions of records. Everything is mo... |
I was recently trying to explain a particular anti-pattern to some novice programmers and found that it was hard to express without an overly-detailed example. I'm sure it has a name and that someone has spent the effort to write a succinct/clear explanation of it, but I have struggled to find it.
The anti-pattern usua... |
I'm building a platform that has an entity named content. There's a clear boundary around what defines content except that it can have relationships with other content entities.
Up until now, there's been no need to know anything about that related content until read-time, at which point my projections have taken care ... |
TL;DR
Why is the UNIX / functional style of composing and injecting smaller functions so much rarer than the Beck/Fowler/Bob refactor-to-objects style when it comes to writing maintainable, "beautiful" software?
Question
In my private projects, I tend to write small functions that do one or perhaps two things, which I ... |
I have a list of application configs and business configs in a particular root folder inside our git repository.
Below is our current structure as of now:
We have a root Data folder and inside that we have multiple sub-folders which has bunch of application and business conigs.
Each sub-folder has different number of ... |
I have .NET Core WebApi application with JWT token for authorization. I also have roles and permissions.
To make it more flexible for end user, I decided to make permissions like this:
[Authorize(Policy = "HasAccessToThisMethod")]
[Route("someMethod/{id}")]
[ProducesResponseType(typeof(int), 200)]
[HttpPost]
public asy... |
Context
Espressif's embedded development libraries for the ESP32 microcontroller contain an event system based on FreeRTOS.
The event system handles connectivity, interrupts and other IO activity, but it's also extensible by the user. It's the latter part I'm interested in.
How is this extensible architectural pattern ... |
The suggested file structure for docker container is something like
root
├── app/
| ├── ...
| └── Dockerfile
|
├── db/
| ├── ...
| └── Dockerfile
...
└── docker-compose.yaml
So where do you put configuration files? If there is any overlap, and the app and the db need access to the same configuration, y... |
My task is to analyze a system used in our office which is based on Excel for storing data. The data is entered manually by a person.
So when we need to update or edit the data, we use Excel's standard features, when new data comes in and we need to print it in a form, we use another Excel sheet to type and print it.
I... |
Background:
We're a smaller shop that puts out a number of products that require
authentication and authorization. We're currently using a 3rd party
service to "spin up new auth APIs" for each application. However, I
would like to investigate potential designs for doing this ourselves
in-house due to additional securi... |
Is capture by value (x below) an early binding and capture by reference (y below) a late binding in C++ lambdas, or are they both early bindings—the first by value and the second by reference?
#include <iostream>
int main() {
auto x = 0, y = 0;
auto lambda = [x, &y]() { std::cout << x << ' ' << y; };
x = ... |
I am working on a project in which I have to read data from liquid level sensor installed in tank which measures fluid level and sends output in millivolt. The device has predefined ranges of voltage to decide fluid level from voltage. The tank might be fitted on moving vehicle as well. I have to represent this data on... |
Currently, we have the issue where we have two codebases (API & Website) calling the same database (along with some duplicate business logic) and we want to streamline this so all requests are routed via our API. We have a public REST API, and we have a website. Some functionality of the website is achievable through t... |
The company I'm currently working for has a feature in an enterprise app where a user can add columns to a table configuration on a web GUI through fields and a button, and a corresponding SQL table has columns added (or altered or removed). That is, the table is shaped in run time by the user's preferences.
This feels... |
Assuming that I have some sort of enterprise accounting software system(web application).
I have many individual companies/customers that use this system.
So each company when they use the system. They use it to perform those financial related transactions. E.g. keep track of who they make payment to, keep track who ar... |
The Main Question
Is it ever acceptable to use a negative name for a boolean variable? For example, I have a few user forms that have a checkbox for "N/A" or "Not Assessed". These aren't going to be used as a part of any query, nor are they going to be used in any complex application logic. These checkboxes exist solel... |
Warning: long question ahead, don't be afraid, I just tried to be as precise as possible about details for who wants them but many paragraphs are skipables if you already understood what I want ;).
Context:
I passed the last few weeks learning Rust (reading The Book, writing small apps and toying), and I'd like to star... |
I'd like to create a web API. It would be used on my websites and potentially by others as well. I intend to use a single token to authorise users. You see, this API acts as an OAuth2 client (or medium, I don't quite know how to express it) so it needs to be a front-end of sorts in itself to achieve redirecting the use... |
I have been tasked to set up a guide for a microservice solution structure and find myself reflecting on why exactly I do things the way I do them.
I am struggling to find an answer to the question when exactly I want to add a new project to my solution in a microservice context.
Some Microsoft articles suggest you sho... |
Often when I'm doing an operation comparing an array to itself, I write code along these lines:
function operation (array) {
for (let i = 0; i < array.length; i++) {
for (let j = i + 1; j < array.length; j++) {
// do something with array, i, and j
}
}
}
While the runtime of this code (starting j at i... |
From RFC 7231 "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content" Section 4.2.2 "Idempotent Methods":
A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request. Of the request methods ... |
I have two aggregate roots: User and Sketches.
In my application, users can clap for a Sketch. In the service layer, it looks as so:
class SketchService {
constructor ({ SketchRepository }) {
this.sketchRepository = SketchRepository
}
async addClaps ({ sketchID, author, count }) {
const sketch = await ... |
For code maintainability I understand that it is generally better to have code structured like this:
void abc() {
a();
b();
c();
d();
}
Instead of like:
void abcd() {
a();
bcd();
}
void bcd() {
b();
cd();
}
void cd() {
c();
d();
}
As it adheres to the single responsibility prin... |
I simply wanted to know if the internal implementation of the TreeSet class in java is Red Black Binary Search Tree. Ideally, I would think that it is a threaded RB-BST, since it supports iteration over the elements stored in it, and this would be much more efficient in terms of space complexity if the tree were thread... |
I have two classes AST and ASTNode for working with some tree-like data. Both these classes have networkx graph as a field and a node id (integer). For AST this id refers to the root of a tree. These two classes looks pretty similar, but I have splited functionality in a following way:
I use AST for global functionali... |
Let's assume you have a project (e.g. .NET Core) using dependency injection. A database repository relies on a database connection string.
public abstract class BaseRepository
{
// use this when accessing the database
private readonly string connectionString;
protected BaseRepository(string connectionS... |
Im sorry in forward, Im sure I wont be able to express myself well.
Its a game system:
abstract class GameType
{
private $score;
public __constructor($score)
{
$this->score = $score;
}
public abstract function getName();
public function getScore()
{
return $this->score;
... |
I've always been curious on how services such as google/youtube have multiple datacenters across the globe to serve requests faster to users while keeping their whole dataset structure intact. There has to be a "master database", right? But then again if lets say the database is in the US and a server in Ireland is han... |
When commenting code, which of the two approaches considered good practice?
Explain the content of the code, "translate" it to human - readable language, but not provide any explanation regarding why the code was written the way it is, why this and that part are necessary, etc..
Explain the content of the code, as wel... |
I recently had to optimize my graphql API server by selecting only specific fields from the database before returning the actual result to the client. For example, let's say my graphql schema has the entity called Product:
type Product {
name: String!
details: String
company: String
}
In addition to the 3 fields... |
I recognise that this may seem like a basic or easily Googled question, but I've been struggling to make sense of the various resources that describe what DAD is. The Wikipedia article is sparse on detail, and YouTube tutorials have not really been any more illuminating.
What I'd like to know is how DAD operates in the... |
I'm building a data visualization that displays COVID information for the United States, at the city, state, and county level.
The ultimate source of truth are three CSVs published by the New York Times on Github in this repo:
https://github.com/nytimes/covid-19-data
The CSVs are updated once per day with new data from... |
I want to integrate google signin, in our existing user registration system. But not sure which approach will be good in terms of data security + user experience (UX) + speed. Even if its a good idea or not in the below scenario, please suggest.
Existing system:
User logs in using username & password.
Registration:
En... |
While learning about OOP, I have found that the term "represent" is used a lot in OOP tutorials. For example I may find a statement like this: "a car object represents a real life car" (of course an object can represent anything, not just real life entities).
My question is, what does the term "represent" mean in this ... |
Recently I have started rewriting my Rails app to Roda, and encountered a hiccup.
While Rails uses a single CSRF token for the entire application (and stores it in a meta tag), Roda recommends using route-specific CSRF tokens.
So, if I have a table of entities on my index page, and I'd want to edit (and update) some of... |
Context:
We have a page which is composed of multiple sections.
Consider for e.g: A product page with Product details, prices, images & offers.
All the sections are shown one after the other in the same order in which they are mentioned.
Our pseudo code to fetch all this data is as shown below:
public Page GetPageDetai... |
What is the best way of dealing with secondary reference data in event driven architectures?
For example, if you have an event from an "Employee" domain that includes some reference data from the "Organisation Structure" domain (like name of the division they work for etc,) - do you add that secondary reference data to... |
I'm currently writing some microservices, some of them communicating using RabbitMQ, RedisDB, Kafka and other communication streams.
When any of those connections drop, I can't know for sure if a query already executed.
For example, if I insert a new key into a database, and the connection drops, two scenarios can happ... |
In Vertical Slice Architecture (VSA) you are supposed to have a class for pretty much every operation you can do (as I understand it). Some example, also mentioned in the referenced article, are:
Get orders
Approve invoice
Cancel order
So if you want to approve an invoice, it is done via the ApproveInvoiceService cla... |
We are introducing events to our system (I would hesitate to call it 'event sourcing', but we have started down this road). To do this we are still maintaining the same HTTP public 'CRUD' API's, but on each mutation request (POST/PATCH/PUT) the server(s) will now create an event and post it to an 'event store' service.... |
I'm trying to write a program to play a simple multiplayer (it's safe to assume less than 10 players) game where each player has a number of resources.
Every turn the players make decisions that affect both their resources and the resources of their opponents.
For the purposes of a mini-max tree search, the evaluation ... |
I'm working on python microservices based app and I'm wondering how to ship updates.
Let's start by a summary of what I have:
Code base on git (several repos)
The app is running on several remote raspberry pis
I access these via vpn network
Raspberry pis have a limited access to internet via GSM MtoM network
The main ... |
I am considering using Azure Service Bus, however my question applies to queues in general.
I have a requirement to send messages in a certain order. Say that the publisher sends a message to the queue, and the subscriber receives the message, but it fails to process the message for some reason (e.g. some business rule... |
A company wants to build an online recruitment system. The logged-in person can add the recruitment application, and attach his CV and some documents.
He will wait for the application to be reviewed by the HR, perhaps for a few days.
The company requests to continue the recruitment process or informs that the applicati... |
I have multiple instances on the same worker that process long-lasting tasks. Usually, those tasks last about 30 minutes - 5 hours. Tasks are stored in RabbitMQ. Workers are deployed as Kubernetes single-container deployment with multiple replicas.
The problem is deploying new changes. I see two strategies here: interr... |
I recently had a discussion with colleagues about the use of futures (std::future in C++) or asynchronous calls in server applications.
On one hand, if you have server logic that needs to access an API on another server, you don't want to block your application waiting on the answer. Using std::future (or the correspo... |
With few years of C programming, I noticed there are two major types of design choices for data organization. I offer an analogy below.
First:
height folder: Andy.txt, Bruce.txt, Chris.txt and Tina.txt
weight folder: Andy.txt, Bruce.txt, Chris.txt and Tina.txt
Second:
Andy folder: height.txt, weight.txt
Bruce fol... |
Background: We have software that displays different products to the user
Problem: With a given set of rules, determine which is the primary product we should show the user. These are images. We are writing this in Python, but I don't think that matters.
Rules:
These don't really matter so I'm just going to abbreviate ... |
I apologize if this sounds really strange. I am very new to System Design and have just been reading up on Event driven systems. To gain better understanding and to perfect my thought process I decided to try my hand at designing a very simple version of a food ordering/delivery system (like an Uber Eats). What I have ... |
What is the best practice to save user informations like firstname,lastname, address...? Directly in the Keycloak db or in the application database and the identifier from the keycloak user will also saved in the application database?
If the best practice it to save it directly in keycloak, would the application access... |
In other words, is it good to define the method that removes an element in a collection inside the class representing the element, considering a composition relationship?
Something like: listElement.Delete();
In the following example, I'm refactoring the code by creating additional classes which are taking over some of... |
Let's use the Twitter API as an example. My understanding is that we refer to /statuses/update as an endpoint and we refer to POST as a HTTP method.
So what would term do you use to refer to the pair of these two things combined, i.e. POST /statuses/update?
"Endpoint". It seems most conventional to also refer to the c... |
I'm currently collecting the data about flat prices. I have size, price, location, price per m2 and date of retrieving the data about flat(sample date). I'm plannig create MySQL database filled with this data, which lead me to questions about appropriate schema.
I have two alternatives at my mind.
Put everything at on... |
I'm going to translate into UML a C++ project I have been doing for a few days and which I estimate convenient to handle as a model for a way better management. The problem is the following: I tried to define a singleton to store precalculated values, it didn't work and the best solution ended to be declaring a static ... |
for example:
type AParams struct {
a int
b string
c []anotherStruct
...
}
//domain/repo/a_repo.go
type ARepo interface {
GetA(params Aparams, ...) (entity.A, error)
}
/// infra/repo/a_repo.go
//the implementation of ARepo interface goes here
...
My question is which layer should I put AParams struct ... |
I've been taking a course on plain language writing, in order to make my commit messages more readable and understandable.
One of the main ideas in plain language writing is that your first identify who your audience is; how do you do this, and what are the usual potential audiences reading commit messages?
|
If all accounts have 2FA for a given product, is there any reason why the 2FA box couldn't be on the primary login screen? Is it bad practice to request 2FA code along with username and password on the same screen? Other than 2FA being optional on some products, are there any other reason why 2FA should show up after s... |
Question, what is a good way to handle large CRUD web pages?
My current process is this:
I make/edit the SQL table with IDs
I get another set of IDs in the HTML form, which is sent to a PHP page
In the PHP page, I put all the SQL IDs in a mysqli prepare statement
Then, I put all the HTML IDs in the bind_params
This p... |
I was reading the Continuous Integration by Martin Fowler article yesterday, the article is from 2006 but I think it is still very applicable today, the statement around a single command stuck in my head.
Automated environments for builds are a common feature of systems. The
Unix world has had make for decades, the Ja... |
This may be too general of a question, but basically whenever I try to find an answer for something that would work from a Javascript approach, the answer heavily implies that you wouldn't do it that way. So I'm asking very generally.
For example, I could chuck both in one array if it were Javascript and then use "ins... |
Usually, when using "reducer pattern" we call reducer a function that takes previous value and change argument that should be applied.
reducer: (state, event) => state
In some cases, it might be needed to use reducer function that already includes changes and just should be applied to the previous value
reducer?: (sta... |
TLDR;
Robert C. Martin adviced here: http://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html
to split the multi responsibility classes into "single reason to change"-classes.
It was not explained, how properties(data), used by more than one of the splitted parts, should be organized/stored/pas... |
I know with NPM caret, tilde and some logical operators can be used to specify version ranges. This post explains a bit on how this works.
The problem now is I find it hard to reconcile the use of version ranges with the idea of having reproducible builds. Version ranges for dependencies means that you are not specifyi... |
I am currently writing a quiz web-app with a React front-end and a Golang backend, with a PostgreSQL database to keep track of the quizzes, the questions on the quizzes, and the choices in the questions.
My approach currently involves having Quiz, Question, and Choice structs, where I've abstracted the SQL away into fu... |
need some advice...I am fully aware that Validation/Syntax Checking, etc. should happen above the Data Access Layer. However the powers that be would like the DAOs to do an extra check. Should when this Checked Exception extend Exception, not be coughed and handled later up? or should I catch this exception and rethr... |
Its an infrastructure monitoring application.
We have a spring boot (2.x) based Service Oriented Architecture (SOA) with multiple modules in our project and the center point is a REST services module which exposes multiple APIs which are in turn used by a client (Angular based).
We are brainstorming over a module which... |
What are some good practices for handling communication between a frontend and a backend?
From what I know in order to keep things loosely coupled you shouldn't just have your frontend have a reference to your backend and directly call it but use some sort of middle layer.
I'm a C# dev and I know of the Event Aggregato... |
Background/Our situation:
Our environment has many components, including database, Windows Server, Linux, ETL platform, Scheduler Platform, and about 5 other types (so 8 total components = code repositories). I would say we have a fairly complex ecosystem with our application interacting with other applications in our ... |
I am currently trying to model IoT devices within buildings. I could start from scratch and develop the data model myself, but this seems like a common problem which will have been solved multiple times before. So I am looking to work from a standard.
I have found various examples including
AWS IoT Constructs https://d... |
I have a web project in. Say, it's in Rails, or any other well web framework. And I plan to be creating copies of it and running them all. Let's say, it's a blog. Each blog will be deployed on its own domain and they basically, 90%, will be identical. And around 10% will be unique, custom on each blog.
Whenever I updat... |
I'm trying to understand what are the benefits of the fact that python defaults to not checking function arguments.
For example:
from some_module import my_function
my_function(some_argument)
# some_argument could be a very complicated data structure
# made of dictionaries and lists.
# I have to depend on the good w... |
We have many different aggregates that use an address entity. But we also have an address aggregate because we have a global address book as well.
Aggregate Company has many Address Entities
Aggregate Agency has many Address Entities
Aggregate Address
From a DDD perspective each aggregate is of course independent. Bu... |
I have a question about the best database schema to do this. So, we want our database schema to carry out some generic operation <> involving two units of data, x1 and x2 (e.g. a1).
// CURRENT SCHEMA of single document in NOSQL db
{
A : { items: [a1] }
B : { items: [b1, b2, b3] }
C : { items: [c1, c2] }
}
Here i... |
The question pretty much says all, but let's look into a simple example (I'm using C++, but the question is not strictly related to any particular language):
So, let's say that we have a functor that outputs many objects (e.g. as a tuple). Is it a good idea to store the outputs to the functor instance rather than retur... |
I have a large Gradle project (2+m LOC) with many sub-projects (50-60). I’d like to be able to version each of the sub-projects separately so that they can be published or released independently. Some of the projects depend on each other, e.g. libA may be depended on by project1 and project2.
I’m interested in whether ... |
Looking to integrate TeX equations in a TeX-agnostic fashion, suitable for either ConTeXt or LaTeX, into a Java-based desktop Markdown editor. The possibilities are numerous, but I'm not sure what approach to take.
JMathTex outputs to MathML, which must be transformed. JEuclid can transform MathML to BufferedImages (no... |
Classes in c++ can be extended, creating new classes which retain characteristics of the base class. This means we can create something like this :
struct Person
{
struct Person** children;
char[20] name;
int age;
};
struct Teacher : public Person
{
char[20] subject;
int salary;
}... |
I have a huge csv file and I have to process that file and do some data manipulation. Right now I'm reading/loading the file in buffer and then doing the data processing work. I find this approach inefficient incase the file is very large. Would it be better to load/read chunk of file then process it and keep doing it ... |
Commonly I see class diagrams where there is no <<class>> stereotype. Others where there is the common <<interface>> and others with some interesting ones as <<shape>> or <<computer>> and so which for a class diagram I personally don't see the necessity but Ok.
I'm making an UML diagram for a modern algebra project in ... |
In C#, for instance, there are static methods for telling if a string is null or empty, finding an element in an array, clearing an array, etc. However there's an instance method for replacing characters in a string, and both static and instance methods for copying elements between arrays.
Similarly, in Python there ar... |
I've been looking in many places about this question - most top Google search results are copy-pasted from a single source, and others are not particularly helpful. Not sure if I am allowed to include the links of my search - so refraining for now.
URL shortening has 2 aspects :
Write : get a long URL, write a mapping... |
I've designed a hash algorithm based on mathematical exponentiation, exponentiating each number by its following number. To be able to exponentiate indefinitely, numbers are first normalized to a 0-1 range. Then, to preserve the ordering characteristic even when normalized, the mean of the list is taken before hashing ... |
I use the "channel pipeline" pattern quite a lot in Go, which looks something like this:
// getSomeNums spits out ints onto a channel. Temperatures, pressures, doesn't matter
func getSomeNums(ch chan<- int) {
// Imagination goes here
}
// double takes numbers from in, doubles them, and pushes them into out
func do... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.