instruction stringlengths 34 36.1k |
|---|
Meta maintains all their code in a single repository and initially used Git. Due to performance issues attributed to the repo's size, they consulted Git's team, who suggested switching to a multi-repo structure. Meta declined this advice and migrated to Mercurial instead.
Given this background, I'm curious about the be... |
A follow up question to How do unit tests facilitate refactoring without introducing regressions?.
I said that integration tests test the behavior of the code, while unit tests, being tied to particular classes and methods, instead test the way it is written. Several answers & comments, if I understand them correctly, ... |
I am trying out CQRS, Event Sourcing and DDD in a project and I want to model a Reminder Service.
The context is as follows: Person A creates a Task for Person B and sets a Deadline for Person B to complete it (also it can be a recurring Task, so when he completes it the next due date would be for example in 30 days ag... |
Designing the architecture of a personal project, I've come up with the idea of using the combination of these two patterns to solve an architectural issue. In an MVC context, I need to implement various types of actions triggered by the UI. I want to abstract the controller from the execution logic, with the model bei... |
Given a service oriented architecture, for example in a blog system let's say we have services for User, Post, and Comments.
A new requirement comes that a User should be able to "Like" any other entity, and any future entity. A user can thumbs up another user, post, or comment.
A new "Likes" service is introduced to s... |
Only loosely related to the title.
In my code I often encounter functions such as this one (e.g. from a pet project – a Discord bot written in Python – but seemingly a ubiquitous and reoccurring issue), which I'm struggling to refactor in an attempt to make it more readable/maintainable (ignore the async/await, treat i... |
Lets say I have a project which is something relatively simple like a copy checker for legal text files stored in git, that multiple people contribute to via pull requests that must be reviewed before merging. I want to alert the reviewer to weasel words, slang etc.
I have split this project into 4 small tickets (proba... |
I am creating a use case diagram for an elevator control system program, and I am a little confused about using includes for sequential actions.
What I mean is that when the user calls the elevator, it is required that subsequently the call button light must turn on and the elevator must go to the called floor. After t... |
I am wondering whether it makes sense to not store informational Data inside the write model database. By informational Data I mean data that is not directly used for any decision making in the write model.
For example take a Product in a Sales context. It would have a name that can be updated. But other than that, the... |
The usual advice for using EF Core in a web application is to use a scoped DbContext per HTTP request. This is even the suggested default for web application in the Microsoft documentation. I recently encountered the argument that this is a bad idea and that you should not use DbContext as a scoped service as it will a... |
I see in arm reference manuals they give info about certain configurations such as
HCR_EL2, Hypervisor Configuration Register (HCR_EL2), and what I read in books and reference manual is that ARM64 have x0-x31 + PC + SP. So where does HCR_EL2 comes into picture?
|
I need to design a system that handles multiple types of resources, each having their own business logic and different types of actions available for those resources. The requirements are a natural fit to have a separate service for each type of resource (not necessarily microservice architecture, at least not at the b... |
I've built a small single-page web application in React and seen that it's possible to serve the app as a static site on something like S3.
Previously, I considered using Nginx, but as this is lower cost I'm thinking of using this method instead.
Are there any drawbacks to this method that I should consider?
|
I'm playing around with AST generation and exploring how it relates to a directed acyclic graph. I hit a logical snag that I don't understand.
var literal = 3; // expression 1
literal = literal+1; // expression 2
Clearly the value of literal is 4; that is, once expression 2 has been parsed. Logically, though, the ac... |
There‘s an approach in unit testing where, instead of just writing the technical details in every test method, you create a library of helper functions like
givenServiceFails (that acts on mock behavior)
whenUserDataIsRequested (acting on the production code) and
thenDataIsDisplayed (asserting mocks or production code... |
Example:
The MacOS API known as Cocoa uses Delegation to specify various behaviors within the app. A Delegate is a separate object that implements a set of methods that are called by an original object. For example an NSApplication calls the applicationWillTerminate method in the NSApplicationDelegate (which is overrid... |
We have built a library which can handle RESTful requests based on configured endpoints.
A fluent builder is being used to create endpoint definitions (configurations). These definitions are bound to a request.
When a request is being executed, the definition is being used to set the correct parameters, like HTTP head... |
I am working with a provided end point that returns a JSON response,
Property "Items" in the response changes depending on:
When there is a single value being returned then it is an object
Items:{SomeObject}
same property when there are multiple items are being returned then it is an array of objects:
Items:[{SomeObje... |
I had a discussion with my boss on DI pattern in C# and I would like to get some reviews and discussion on the following code snippets.
Key points to look into is that the instantiation of the ExternalService and ExternalServiceConfig where there's no interface for DI to register or mock.
Pattern A - Instantiate the Ex... |
I'm programming an embedded system that has a number of user configurable parameters, which are stored in flash memory. I have to store a default value for each parameter as well as the user settings. Because the STM32 I use can write 64 Bits of flash memory at a time, I chose to use one word (32 Bits) for the paramete... |
I am using the Spring Boot framework to create a RESTFUL API and I need a way to avoid the duplication of validation rules when using multiple DTOs as request/response objects for my endpoints.
Using the following example for the Entity
@Entity
public class Post
{
@Id @GeneratedValue(strategy = GenerationType.IDENT... |
I'm making a vpn service that can be controlled through admin web page.
So I have a web page that consists of front-end page and a backend API + DB.
In this admin web page, I can execute a vpn binary at my server by clicking a button or submitting a form. And also set some configurations before I start my vpn-service.
... |
Per the UML 2.5.1 specification:
DeployedTargets are shown as a perspective view of cube labeled with the name of the DeployedTarget shown prepended by a colon. System elements deployed on a DeployedTarget, and Deployments that connect them, may be drawn inside the perspective cube. Alternately, deployed system elemen... |
Are the reasons for why Microsoft states that DB contexts should not be long lived because of measurable effects (memory leak, resource hog, increased probability of data corruption, ...) or is it because of a more subjective reasons (anti pattern, hard to manage multiple instances of the same record, increased complex... |
Typically the solution for comparing if 2 relational db tables (I am using AWS Athena) are equal is to do full outer join on all the columns but adding an extra column to each dataset that acts as a marker.
select *
from
(
(select *, 't1' as t1 from table1 where ...) t1
full outer join
(select *, 't2' as t... |
As I understand it, the join() method merge/composes/combines the results from all subtasks. A simple example I saw was summing the numbers from 1 to N and the subtasks would simply sum a range of such numbers -- obtaining the final result very naturally involved summing each subtask's result to indeed get the right an... |
I personally put build stage in Dockerfile. (Using multi-stage feature in Dockerfile)
But in my company, we have dev containers where all dependencies are installed and managed. So in our product's Dockerfile, there is no build stage. Build(compile) is done on dev containers and result binary are copied to Dockerfile. ... |
When you define a class, is inheriting a logger such as log4cxx a good design?
Assume I am defining a class called MyClass.
When I want a logger, I use a pointer to an abstract logger class as a member variable of MyClass. Then during the construction of MyClass, I can pass in a pointer to a concrete logger class in th... |
I am currently analysing the project ddd-library which is really helping in learning designing a system based on DDD principles. However there is one thing I have a problem with.
In case of placing a book on hold, first the Patron Aggregate is updated (it holds now a book) and then the Book Aggregate is updated. Whethe... |
My team own two micro-services, both hosted on AWS ECS. One service uses aws redis. For second service we need to implement lock mechanism for one endpoint. For that we need to store single key in redis. I propose to use same aws redis infrastructure. One point raise as its against bounded context of first micro-servic... |
In his "Software Engineering. Principles and Practice," H. van Vliet mentions "tree impurity of a call graph." However, the term tree impurity is not used in this meaning anywhere else but refers to decision trees in machine learning. Did H. v. V. misuse the term in his book, or has the term recently lost its original ... |
I tried searching the web but can't understand the difference/boundary between hexagonal(ports and adapter) architecture and ACL Pattern.
While hexagonal architecture talks about creating ports(interfaces) and adapters(implementation), doesn't ACL also do same by adding a layer which is corruption free and isn't impact... |
I’m writing a web application with an Angular client and a Pyramid/Python server. I need to dynamically interface with an external cloud application, with two requirements:
When the end user approves an invoice in that external cloud application,
the Angular client should automatically open in the browser and show the... |
Just to provide context:
I am modeling a ticket (service management) process and specific actions are allowed in specific life cycle stages, so not in a straight sequence flow.
Therefore I encapsulated the respective task in a subprocess that now has several boundary events.
E.g. adding notes to the ticket. That can be... |
So, I recently added some validation logic to our controllers:
interface Validator<T> {
fun validate(model: T): Boolean
}
Which is used in the controller like this:
validator.validate(request) || throw Exception()
During code review my colleague was thrown off by validate || throw construct, while to me it is suc... |
I have a large R project developed in a Windows environment which I want to move to Linux, and there are lots of Windows style directory references (assigned in variables at least) which I assume I will need to translate. There are various folder tree references in the code.
Is there an easy way to do this, other than... |
I was writing a procedure that is only applicable in a particular case, but it didn't feel right to enforce it by contract or raising exceptions, because there's no problem with calling it in other contexts; it just shouldn't do anything.
Thinking about it, I decided it would be easier for future debugging if I explici... |
Most template engines have two ways to refer to other templates:
Inheritance with blocks (child template inherits from parent template and fills one or more blocks)
Includes (parent template includes child template).
Coming from vanilla PHP require/include and from component based JavaScript frameworks, I never reall... |
I have a service A that every once in a while needs to send a message to a cluster of services B1, B2 ... BN.
Then all of these services need to receive that message reliably, and send a confirmation back to A.
After A receives the confirmation from all services from cluster B, it needs to send a message to another clu... |
For example, I have a Business Intelligence (BI) microservice, it reads data from other microservices, and displays the data as a bar chart or some other styles.
My problem is, the BI microservice needs other microservices to register the display content and some rules, and the BI microservice reads and displays the da... |
I am going through various virtualization concepts, and am trying to understand their benefits.
Based on what I have read, Amazon EC2 is an example of server/hardware virtualization, and it helps us achieve high utlization of hardware. In the absence of hypervisor, we would have low utlization rate of hardware. Also, s... |
HINT: the purpose of this question is to identify downsides for the scenario described. If something is a downside, then it should be quantifiable and it should clearly have a negative impact.
Background:
I'm working in a project for which we take a yaml file with some values and use those to render Jinja2 template fil... |
I am trying to devise a simple system that, with the use of tokens, allows a specific file to be rendered in the client's browser, yet prevents the user agent from being able to download the file. Below is a simplified description of the process:
A user agent or client requests the web page from the web-page server.
T... |
I’m working on an application that requires many 3rd-party integrations. I’m using Postgres to store these API responses but am having trouble for a number of reasons.
These objects are frequently large and require me to model the relationships to fields.
Many 3rd party responses have some sort of inherited relationsh... |
I need help with the architecture pattern I should use in a NestJS project.
So I am using a command/query approach for developing my RestAPIs. Right now it's a Monolith and not a microservice architecture, but I am developing it in a way that tomorrow it will be easy to switch to Microservice.
So consider a scenario, w... |
I have a NextJS app for which I want to cache data from our backend APIs to reduce the load when we have high volumes of concurrent users scrolling through (or search) years-worth of historical data.
Data flow is unidirectional with the cache only ever being updated via our APIs. Cached data is eventually consistent. I... |
I have a "Games" API which retrieves video game data from a large database.
The /games endpoint returns some very basic information about the game, such as the title, description, etc.
More detailed information, such as the developer, is actually not given by this endpoint. Instead, a reference ID, to be used for anoth... |
What is the most complete way to test an imperative function? By "complete" I mean, something that is robust, that tests all the edge cases of the function, that so much as "proves" it to be correct. Ideally it isn't brute force, but if it has to be that's fine.
Say you have a really complicated function. You break it ... |
I am a Computer Science student and one of my first class was Object Oriented Design (Java). Unfortunately, we never interacted with a database during that class. I am currently working on a CRUD app as a side-project and I am confused about the relationship between Objects and DB Tables.
Let's say I am making a persis... |
Reading Domain-Driven Design, on the section of Aggregates, it says
The root is the only member of the Aggregate that outside objects are
allowed to hold references to, although objects within the boundary may
hold references to each other.
The Application Layer is the direct client of the domain model.
Can objects o... |
Client_1 uses --> IService_1 and thus Service1_impl
public interface IService_1
{
void DoTask_1();
}
public class Service1_impl : IService_1
{
private readonly IDepService_1_v1 _depService_4;
private readonly IDepService_2_v1 _batchdepService_4;
private readonly IDepService_3_v1 _depService_2;
pr... |
I'm currently make a Helper class that can be used by multiple team members. Helper class uses third party API. And I have a question about that handles exceptions in the Helper class.
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/creating-and-throwing-exceptions
Looking at the link above,... |
I'm developing a text editor and start to think about key bindings.
Which F key (F1, F2, F11, etc.) should I use in my application, assuming that I want OS X users to be able to use it as well? I don't want to bind keys that are already used in Windows, Mac OS or Linux common distributions.
|
I am writing a new application where the clients want to communicate using files over (S)FTP.
The first use case is that the client puts a file on the FTP server at end of day.
I then process it and upload it line by line to my REST API.
The second use case is that there will be 2 or 3 drops intra-day for error process... |
In my experience, all languages I know have a sort of "positive" type system. What I mean by "positive type system" is that when you are writing the source code, you always specify what types your function/objects accept, like:
function f(SomeType argument) { ... }
But I have never seen something like:
function f(Abst... |
Please help me with the following code refactoring, I spent so much time researching it and there's still no clear answer on how to approach it. Any help is greatly appreciated!
So, given 2 methods (C#):
private void func1()
{
int i1 = 0;
bool b1 = false
foreach (Object item in List<Object>)
{
... |
I was recently part of a TDD development team. At certain point I realized that there is a design mistake instead of Object Oriented Design and Structural design the problems were solved via statuses. Tens of statuses. For a brief moment I thought - Hmm... maybe I can actualy try to do some modeling and reduce the stat... |
I have a set of UUIDs that I want to assign to a set of people. I want to deliver these UUIDs to people in a secure manner, such that everyone knows that I do not know which UUID corresponds to which person. I.e., I want it to be publicly verifiable that the assignment process was random and that the delivery process w... |
I have a stream of documents, each having an ID which is a 64 bit unsigned long given as a (maximum length is 20) string.
Sometimes an ID appears multiple times in the stream. I don't want to process a document if I already processed it, so I'm using Redis to cache last 20M document ID's. If 20M is exceeded, cache can ... |
I am using DDD pattern in login micro service used in employee management software. Here Organization/Company is an Entity and User is one more entity.
What are my aggregates in this case, if i think with project in mind which is login i will have only one aggregate(user aggregate) but if i think as business in my mind... |
I'm trying to understand the following description of implementing the visitor pattern with an internal iterator. It is from the GoF's Design Pattern Elements of Reusable Object-Oriented Software book Page 339 (More context is provided below and in the online version).
The main difference is that an internal iterator ... |
I have to replace an old application (Database, C++ UI) which is mainly for data administration, with on a new application (Same Database, Spring-Boot, Angular).
We want to document how the application (the old and the new) handles every attribute. That is:
Name of the attribute
Type of the attribute
Location in UI
Lo... |
In our organization we sometimes have to create a poc (proof of concept) to either validate or invalidate the way to go. Currently we're having a discussion around how to embed this within our development/testing process in the app and thus the same repo itself. It would be nice that the poc can enter the internal test... |
I've been told on StackOverflow this questions was off-topic so I'm asking here:
From this webpage (ISO/IEC 22275:2018):
This International Standard defines the ECMAScript Specification Suite containing the ECMAScript programming language and its required and optional built-in libraries.
As I understand, ISO releases... |
Is there an idiomatic way to catch an exception when multiple methods may throw?:
try:
someMethod() # raises OSError
someOtherMethod() # raises OSError
except OSError:
handle()
The exception may or may not be caused by the same event internal to the helper functions, so in the current layout it seems imp... |
I'm trying to figure out how to integrate one command that updates multiple Aggregates in different contexts in a video game. The components/considerations for my particular design are DDD, CQRS, Ports and Adapters, Event-Driven Architecture, Aggregate+Event Sourcing, and Entity-Component-System. It's a lot to manage, ... |
There are many ways to secure the REST APIs, from authentication and authorization view point. Below are the two which I know so far:
Using existing token based IAM solutions like Okta, KeyCloak, Auth0, etc.
Pros: Already proven solution, feature rich, easy to start and run
Cons: Difficult to customize as per needs a... |
I have a 'processing' function and a 'serializing' function. Currently the processor returns 4 different types of data structures to be serialized in different ways.
Looking for the best practise on what to do here.
def process(input):
...
return a,b,c,d
def serialize(a,b,c):
...
# Different serialization ... |
To set up the problem, let's imagine we have a downstream service that we need to call for some information. We set up an API endpoint and call another method which will hold our business logic and make the HTTP request. Based off of certain parameters that were sent to this method, we may potentially have to make seve... |
I want the user to be able to provide a custom WHERE statement against a mysql-backed platform... do I need to worry about any possible SQL injection attacks notwithstanding invalid sql? See the pseudo code below.
return sqlExec("select a,b,c from mytable where %s", args[0])
Okay, in all seriousness I can see where th... |
The standard way that types are handled in programming languages that have such a concept, is that they are:
removed entirely at compile time and are just used to determine memory layout, function pointers etc...
left in some form as a sort of tag on a structure in memory, so that you can check if B instanceof A and s... |
I am working on a spring boot maven project in Eclipse IDE. And here is my pom.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/mave... |
I am working on a personal project for more than 6 months now, this project is composed of three distinct parts, simulation (wrapping a software),
database related stuff (store the simulated data in a database) and modelization (a lot of machine learning related stuff)
To manage my config (paths and few constants) I st... |
CI/CD options such as bitbucket pipelines and github actions make use of virtual machines called runners. Changes in source code trigger the runners, which in turn trigger a set of commands. The commands may include instructions to run a test suite. The test suite checks whether source code changes break existing funct... |
I often define variables that will never change, i.e. constants, at the top of a script/module. But recently I've been wondering if it makes sense to define them at the function scope level if they are only used by a single method.
LIST_OF_THINGS = [('a', 1), ('b', 2), ('c', 3)]
def some_op():
for thing in LIS... |
Is there any specific category an ADT must be in? I'm struggling to find out how best to represent objects in the program for example:
As a record:
struct Person {
int age
};
Or as an ADT:
struct Person { int age; };
typedef struct Person* Person;
void Person_SetAge(Person person, int age);
Both represent the s... |
Currently I have an structure of PopUps and I've been thinking to use Chain of Responsibility pattern, but the difference is a popup can back to previous one PopUp and also can go to any other PopUp.
I've been thinking to use chain of responsibility, but I think maybe is not the Ideal once chain of responsibility only ... |
I have a REST API server with its own authentication methods. I need to provide to some third party apps an authentication solution which should be processed on my server, I don't want them to handle the user's credentials.
After some research I found that in order to avoid using a third party solution as Auth0 I may n... |
In his book Implementing Domain-Driven Design Vaughn Vernon suggests to reference other aggregate roots only by identity and not by reference, like this:
// Aggregate Root
class Order(
val customerId: CustomerId // reference by ID
)
He argues that this would prevent accidental modifications of the referenced aggrega... |
Background
Tertiary to this question, I have been building my own imageboard that prevents [for example] duplicate images from being downloaded again and again on behalf of the client. How I do this, is that I keep all files in a database with a key being a hash of the file. The client sees the hash, and first checks i... |
In AWS you can easily create a RESTful API using API Gateway. With a serverless approach, you would have API Gateway integrate with Lambda to handle your endpoint logic. This seems like the most obvious approach, as its very elastic and cost effective, however, looking into architectures for large companies, most of th... |
What is the right software license to use in order to be able to sell my application, have it be open-source, and still be able to accept pull requests?
I am developing a productivity/utility application for Windows. I would like to release that application on the Microsoft Store as a paid application, with a free tria... |
I have been developing control software in C++. My hardware consists of a microcontroller with an integrated a/d converter and an external on board a/d converter. Both of these a/d converters have different features but there are some commonalities (both of them are capable to offer value of
given analog input).
// ana... |
I'm trying to figure out how to structure a 3rd party integration microservice, and how to name the classes accordingly. If you had a classic shopping cart application which processed payments for different credit card vendors(Visa, Mastercard, etc), this would be for a credit card microservice for exactly one vendor.
... |
I have some fairly complex code, that is a chain of API calls. The result of one call is the input of the next.
class PaymentService {
func pay(userId: String) async {
let paymentSource = await thirdPartyService.createPaymentSource() // A
let order = await orderService.createOrder(paymentSource: paymentS... |
We have a microservice that integrates with a third party system via REST API to handle appointment booking for our customer. It takes advantage of the event-driven model. Our microservice emits out an integration event called the AppointmentCreated event post-appointment booking with the third party service.
The Appoi... |
Firstly, this is a really tough topic to do searches for because you get a wealth of information on “code review”, which is different from what I’m referring to here. That normally refers to reviewing new code that is being introduced into the codebase. That’s not what I’m interested in here.
The basic problem: You ... |
In software engineering, often developers will utilize three different states of a signed integer, as a trilean:
This tends to be quite typical:
-1 - Represents something akin to a null pointer, as in it has no initiation or use or meaning
0 - Represents zero or false
1+ - Represents a valid value
In this case of QIO... |
Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array that was at least one bit smaller, with apodictic certainty that no collision would occur.
The answer given to me by on... |
I work with Python classes that define properties that return some privately managed data member. When accessing this data in the body of other methods, is it better practice to use the public or private interface?
class A:
def __init__(self):
self._x = something
@property
def x(self):
return self._x... |
So, today I was reading a piece of code I found this function:
Public Function FolderExists(sPath As String) As Boolean
Dim FSO As New FileSystemObject
On Error GoTo errHandler
sPath = Trim$(sPath)
If sPath = vbNullString Then Exit Function
FolderExists = FSO.FolderExists(sPath)
Set FSO = Not... |
I am currently working on a library that provides functionality for interactive terminal applications.
For now, I implemented functionality for reading an arbitrary keypress from the User to the application as well as setting the currently active color.
I want my library to support a broad spectrum of terminals on diff... |
Take the following signature
BigInt* addBigInt(BigInt* arg1, BigInt* arg2);
Traditionally, the safest way to implement this function would be for it not mutate the arguments, and would necessarily need to create a new object to result for the operation. Alternatively, if the aim is to conserve on system memory, arg1 c... |
I am working on a python framework for building a special kind of editors (so they have GUI) and I just split it into backend and a frontend (distinct libraries), s.t. another frontend could be implemented in the future. I started the project with Qt (PySide2) and because there is potential for realtime data processing... |
I am working on low level design of cab booking type of system and feeling stuck at modelling Vehicle in Booking class.I came up with following design.
Class Vehicle
{
}
Class Car extends Vehicle
{
CAR_TYPE type;
}
Classs Bike extends Vehicle
{
}
... |
The book Design Patterns: Elements of Reusable Object-Oriented Software says to use the builder pattern when
The algorithm for creating a complex object should be independent of the
parts that make up the object and how they're assembled.
The construction process must allow different representations for the
object th... |
I think download rates may depend on these 3 factors: the Network Infrastructure (router, VPN, network card, towers), the RAM or cache, the Final Storage (HDD or SDD or whatnot).
So we take this as an example: I have a very slow HDD Drive and very slow RAM but a very fast network adapter & router.
When downloading, for... |
I am brain storming on how to create a type system for a programming language, and what the compiler will do with the typing information. Here is what I have found, followed by the main question, which is if I can represent more complicated "validations" as types somehow.
First, it seems there is a difference between t... |
Suppose we have a code:
for(int i=0;i<n;i++) sum+=i;
We say the time function here is: f(n) = n+1+n = 2n+1. The order of the time function is 1. So, our time complexity becomes O(n).
But, for the following code:
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j*=2)
{
statement;
}
}
For this code our time ... |
I am building a storage engine software that allows concurrent data writing, now I have two different choices here:
Method 1. Background Long-Running Thread
Multiple user threads write to their own WriteBuffer
A background long-running IO thread iterate all write buffers and flush each write buffer one by one. (Need t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.