instruction stringlengths 34 36.1k |
|---|
In Javascript, the iteration order of an Object is enforced since ES2020 (or before, depending...).
However, is it a good idea (i.e. best practice) to depend on this?
I'm currently working on a website where the backend (NodeJS) needs to send a map of data to the front...but the keys need to follow a certain order (def... |
I have a git repo with nested submodule dependencies (see picture as an example). There are duplications because each repo needs to be compiled standalone in a pipeline so that the corresponding test executable can be run. Currently, this is solved with submodules. If E gets a new commit, I need to
update submodule po... |
In java we generally do it the java-docs way and in js the popular method these days is vscode documentation using @param, @returns, @example etc but I would prefer if there were some language agnostic and IDE agnostic way to do so; probably, backed by some RFC; anyways, the most I can come up with is using markdown wh... |
I would like to be able to build up a log of user activities, capturing data such as who they were, where they logged in from, what activity did they take, and what data did they change (both before and after).
Most of the user-related data can easily be picked up by middleware running on my web server, that can hook i... |
Loose coupling promotes testability because it allows components to be tested in isolation without having to test the entire system. This can help to reduce the risk of introducing new bugs by making it easier to identify and fix bugs before they are integrated into the system.
How can testability help in identifying a... |
I have been doing a lot of thinking lately about the implications of event-based/responsive programming and UML statecharts.
I believe my thinking up to this point has been flawed. Take, for example, a toggle button/switch. It has an internal state: pressed or released. It also generates events: press and release. T... |
We have 3 subscriptions in our Azure management group: DEV, TEST & PROD
We use Azure Maps to get weather insights data via some Databricks jobs
In order to roll things off quickly, we replicated the setup in all three environments and all is working well
Now as a part of efficiency and cost optimisation, we want to reu... |
I'm trying to better understand cohesion and coupling. More specifically, I'm trying to use examples to better cement the concepts and one of the most common examples I see goes something like this.
For this "bad" code
public void Process() {
string connectionString = getConnectionString();
SqlConnection connection... |
I have a time-series database where I put all my data in it in timely-ordered fashion. Unfortunately, the database doesn't have any realtime listener capability built into it, and I need to make an app that responds to any changes happened to my dataset.
Using that as the context, I came up with idea to regularly query... |
For learning purposes and fun, I created an Expo Go app with react-native for recipes. It has a firebase database and uses redux to manage state locally on each device. So far so good. A couple of friends are actually using the app encouraging me to improve it even further.
To get started, I decided to load all data on... |
I work with a integration project based on Publisher/Subscriber pattern whose subscriber end feeds a staging database which stores data to be pushed to another application. The staging database has some views which are responsible for providing data the the final application
We use DataDog for observability, but since ... |
According to What is a "side effect?", I know the side effect means changing outside world. But what if a function that changes the outside state during execution, but reverts the state to original state after execution? For example, originally I have a function about physics simulation that doesn't modify the outer va... |
In the Collaboration diagram, we represent a message with a solid-headed line :
Moreover, in a sequence diagram, we can show a synchronous message with a solid-headed line and an asynchronous message with an open arrowhead:
Is there a way to indicate a synchronous and asynchronous message in the collaboration diagram... |
When creating a distributed web application, cache invalidation can be a big deal. However, our web application doesn't need distributed load, as we don't expect to serve more than 1k users at a time. For now, we've had a multithreaded asynchronous web application written in Rust. The web application is run on only one... |
In UML we have two special messages, create and destroy. These two messages describe the creation and the destruction of objects, respectively. We must use the stereotypes << create >> and << destroy >> for them. In the UML sequence diagram, I see that sometimes we create a message using a closed solid arrowhead and s... |
I need to process status changes related to an entity in a sequential order. Not in parallel.
Will an SQS FIFO Group with MessageGroupId = UserId be enough?
Let's say I have the folowing messages:
MessageGroupId = 1, status: :pending
MessageGroupId = 2, status: :pending
MessageGroupId = 1, status: :approved
And I hav... |
Should one enforce reasonable values when modeling one's domain?
Here's an example:
Assume that we have a scheduling application that schedules visits for people who require assistance and normally one would not schedule a visit more than a maximum of a year in advance. Should I then enforce that by saying that a visit... |
I'm currently writing an MVC application and I need a class that can:
A: get, add and remove data(specifically a TreeSet of sorted strings that I want stored in memory, but I doubt the data itself is relevant.)
B: The data must be accessible to multiple controllers.
C: There can "presumably" only be one instance of thi... |
I work within a poly-repo that is worked on by multiple other teams, each in our own separate sections of this main repo.
I am coming to make my first push to production and I am unsure about strategies for doing so.
A traditional code-freeze on the Master branch isn't feasible due to the amount of teams and the freque... |
I am storing a large (~1M per year for ~30 years) amount of text files in file-based storage. Each file is named
FFFFFFFFFF-YY-SSSSSS.txt
where FFFFFFFFFF is a 10-digit filer key, YY is a 2-digit year, and SSSSSS is a 6-digit incrementing sequence for each filer in each year (so it starts at 000001, etc.)
I wanted a s... |
I have been asked to give a 45 minute talk on my team's system architecture to an incoming product manager (PM). Well, this PM's "mentor" highly recommended asking for one.
I'm comfortable giving this talk to a room of engineers—we use gRPC, microservices, GCP—we own some of the source of truth in a Postgres database, ... |
I'm trying to experiment with SOLID in order to get a better grasp of its' concepts. With that in mind, I'm making a card game project.
There's a GameUtils project that contains the following classes: IPlayer, ICard, and IDeck.
Then there are projects for each game, such as Hearts, GoFish, and War. Inside those proje... |
When talking about integration level of automated tests, I suppose that end-to-end tests lie at the first extreme: they know absolutely nothing about the internals of the app they test, they just run the app and see if it behaves as expected. On the other extreme, unit tests in the classical sense lie: they test only a... |
The second and last question in my current series of questions about TDD and unit tests...
For the purpose of this question, a 'unit test' is defined as a test that focuses only on a particular method and that mocks all dependencies of the class of this method. (As opposed to any other sort of automatic test, such as a... |
Lombok is used in the legacy project where I am currently working for since last year. The project is legacy with 10+ years, and POJO/JavaBeans, i.e. @Data annotated classes, have been widely used for probably 10+ years.
However, since I have been using Lombok for many years in other companies, I just prefer to using t... |
We all know the standard TDD cycle: I first write a unit test, the smallest unit test that fails; then I write some production code, again the smallest amount of production code that is sufficient to pass the test; finally I refactor. In this way, it is hoped, I will produce code that is 100% covered by unit tests.
Not... |
I have the following operations:
User submits event
We store event in a queue
Wait for events and store them in db for redundancy
Wait for events and process them
Remove events from queue and db
For performance reasons, op 3 runs on a different thread.
The queue is always accessed under a lock, since events are submi... |
When you look at products like the Razor view engine, there's a clear reason why Microsoft decided to subset another existing standard (HTML) with their own special sauce thrown in.
But I cannot find any concrete examples why Microsoft decided to subset XML and go with a completely identical standard: XAML. It seems li... |
I am working on building a workflow orchestrator (like Camunda). It has nodes of type event. This represents a message has been received in the kafka topic which the orchestrator is listening to. The workflow orchestrator now gets the related workflow instance, mark current node as completed and runs the next node in t... |
Consider the following level - 0 dataflow diagram for a patient management system :
Consider the doctor entity, the system provides an appointment report to the doctor. If the system only generates the report upon a request from the doctor, do I must include an outgoing ( from the doctor entity ) dataflow labeled as f... |
I have a singleton that needs to be initialized at the start of the program and it will live on until the end of the program. As is usual in this pattern, a function initializing the singleton creates a static pointer member to itself that is returned from the get() method. My usual C++ instinct tells me that if someth... |
I'm designing an Azure Service Bus topology with multiple topics. Each topic is associated with a single message type: this is possible since we have a limited number of message types, each one with a well defined semantic meaning in the business domain. Each one of this messages has the meaning of an event inside the ... |
From the book Essentials of Systems Analysis and Design by Joseph S. Valacich, Joey F. George, Jeffrey A. Hoffer, we have a study case, with the following 0 DFD :
This diagram raises the following question:
Why do we have the data flow Product Item: Does this flow mean the system is adding a new item to the inventory... |
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know "init()" method is a code smell, and "physically make them two separate classes" is a way to refactor the "init()".
However, I don't understand what is the meaning of "physically make them two separate classes". Is it mean move the init ... |
For example:
After I've learned about SQL injections I realized that in past projects I didn't check user inputs for SQL injections.
After I've learned about PKCE I realized that in past projects I didn't use PKCE in OAuth 2.0.
Each time I have these enlightenments, I feel bad about my past projects. My inner voice s... |
I use code like this and it seems to work fine:
void addActions(const vector<zero_arity_function>& _actions)
{
actionsMutex.lock();
for (auto entry : _actions) {
actionsToRun.push_back(entry);
}
actionsMutex.unlock();
}
And the corresponding code that the other threads runs:
void runActions()... |
We have some domain primitives for representing an Account an Amount with Currency etc.
These are in a shared library, so all our microservices can use them.
And then we started adding some convenience methods like Amount.of(String currency, BigDecimal value) and Account.fromIdentifier(String) etc.
These are really con... |
In my current workplace, I act as lead developer and architect in a team of software developers.
The general policy for merge/pull requests is that 1 person has to review and approve the request. This person must not be the author.
Sometimes code is merged which I personally would not have approved for one ore multiple... |
I want to model a system where someone is creating Quiz and he can choose who should do the quiz. When submitted the invited people have a deadline to solve the quiz and the creator and maybe some other guys have the authority to see the status of each Invitee, whether they finished it or not. (Basically it is kind of ... |
Given the two models company and person I'm noticing duplicate fields i.e. zipcode, emailaddress for each.
Yet, a short research reveals a reasonable popularity for separating those two entities into two tables (in terms of customer relation management databases [crm]).
Would one contact table with appropriate fields o... |
It's been a long time that I had an idea of a semantic constraint as compiler optimizations which allows for sophisticated high level optimization allowing you to transform the AST/CFG based on a SFG (semantic flow graph).
To give you a simple example I'll simplify the code of a reddit question which asked about two ve... |
I have to update app code running in a container on AKS to use a WorkloadIdentityCredential. I have to test code that I update in order to pass CI quality gates.
The code uses a public final class, com.azure.resourcemanager.AzureResourceManager, whose constructors are private.
The only way to get a new instance of this... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.