instruction stringlengths 34 36.1k |
|---|
I've been learning about threads and processes and I understand that threads allow you to write concurrent code: where executing threads switch very quickly from one to another, giving the impression that multiple programs are running in parallel (but not truly in parallel, for which we would really need parallelism us... |
I need to perform the following task: for a user user@domain.com, store a blob of data into their dedicated data store.
DataStoreService is what actually stores the blob of data in the user's store, however it needs a StoreClientFactory which owns the logic for picking which store belongs to the given user.
StoreClien... |
I'm required to write the Low-Level Requirements of a Software Component which shall perform signal processing over arrays of 200k elements of integers/floats which lives in the main memory of the program. The program is single thread.
The software shall be certified in the context of DO 178-C (DAL-A).
The signal proce... |
Say I have a module that can to do two things: It can check if condition A is met and it can create an artefact B. The caveat here is that if condition A is not met, artifact B should not be created. If I am calling this module from the outside, should this check be performed by the caller or by module?
Version 1:
// O... |
I have Service A that publishes an event to RabbitMQ. I have two instances of Service B that will use the event to write to its database. I have two instances of Service C that will send the event data back to a client via websockets.
Only one instance of Service B should handle the event so data isn't written to the d... |
I have a system design question that I'm looking for some guidance on. I have two different systems that need to have a basic level of communication. This is abstracted via message queues.
For example, System A is responsible for user account registration. A user access System B and enters the user registration flow. A... |
I am currently learning system design. I wonder if I should put load balancer in front of multiple instances of API gateway or put an API gateway in front of single load balancer. which one is valid design?
|
... or technology stack for compliant web applications.
GDPR among other includes cookies usage defining four cookie types: strictly necessary cookies , preferences cookies, statistics cookies, marketing cookies.
I am researching for a solution to develop a stateful web application without using cookies to avoid gettin... |
I've recently just noticed that IDictionary does not implement IReadOnlyDictionary. I'm using two third-party libraries, one of which provides a ToDictionary() method which returns an IDictionary containing the contents, and another which consumes an IReadOnlyDictionary. In order to make this work, I've had to write th... |
According to Origin of "a method should return a value or have side-effects, but not both", a method should either return a value or have side-effect, but not both. However, I often see some situations that I need both the result of modify objects and the process of modifying it, for example, a function that modify an ... |
From the article JavaScript 2D Array – Two Dimensional Arrays in JS, I see one way to store data is to put all properties of each element into one array:
let dataRepresentation1 = [
['John Doe', 20, 60, 'A'],
['Jane Doe', 10, 52, 'B'],
['Petr Chess', 5, 24, 'F'],
['Ling Jess', 28, 43, 'A'],
['Ben Li... |
A module app.js includes another module service.js. The service.js module/file contains some functions but also does some module scoped initialisations(registry variable).
// service.js
const registry = database.connect()
function getItems(){
const items = registry.getItems();
return items;
}
function doSomethingE... |
I'm working on a fairly large but standard dotnet core API. Here's a simplified sample:
// Simplified example of a controller
public class VehiclesController : ControllerBase
{
private readonly IVehicleService _vehicleService;
public VehiclesController(IVehicleService vehicleService)
{
_vehicleServ... |
I'm not sure if this is the right stack exchange site for this, or maybe this is more of a reddit question, but don't rake me over the coals for asking. Happy to go post on another corner of the internet if need be.
I'm wondering what would be the best approach to identifying duplicate transactions within an accounting... |
I am curious about the utility of something like monads in the C# world.
My experience with these kinds of things is mainly through Rust but I'm a dotnet dev for work
I was thinking about the difference between Rust's result type and exception handling
https://doc.rust-lang.org/std/result/
The scenario I'm thinking thr... |
I'm relatively new to structuring code in a composition style, and I have a situation where a component is also a component of a sibling component. I'm trying to figure out if there are likely to be unexpected issues with this.
Explaining the relation in more detail, I have a composite C that has components A and B. Ho... |
Assume that we are doing aggregate design for a ride hailing application and we have created the following aggregates: DriverAvailability aggregate, which has a value object containing the status (available/unavailable) and DriverLocation aggregate which has a value object which contains the latitude and the longitude... |
Context: This is from a practice exam, and we aren't sure what the proper answer was
Question: What is a possible order of actions for this activity diagram?
Options:
A->B->D or A->B->C->D
A->B->C->D or A->B->C->D->E
A->B->C->D->E or C->A->B->E
A->B->C->D or C->A->B->E
Diagram is illegal
The first bar is called... |
I am the maintainer of a Python library that uses semantic versioning. Skip the next paragraph if you are familiar with what it means.
The rough and dirty explanation of semantic versioning is as follows. The library developer uses a version number of the form MAJOR.MINOR.PATCH where the first two components are increm... |
We're trying to update our style guide (using google's guide as a starting point) and I'm currently in the middle of a debate with my colleagues about column limits. I believe we're all in agreement that they're generally a good thing, however I'm upset that a string (or simple string template) assignment would necessa... |
Most weakly typed languages do not have a concept of a pointer. Instead, most of them use references. However, is it possible to introduce pointers to such a language.
From a naive point of view, to have pointers, you almost certainly need to have a concept of a type system that can be used to declare things (which mea... |
I want my projects to be SemVer compliant. I follow a trunk-based development approach. I also want to keep things as simple as possible.
I assume that each commit on main (default branch) is a possible release candidate. So my CI/CD pipeline looks at the M.m.p version number in the codebase, and build & release artefa... |
Over and over again we're told, "globals are bad" and with good reason. However, I'm working with a logger that needs to be accessible everywhere in the program. Why shouldn't I create a global logging object? The alternative seems to be to pass the logger object into every object I instantiate and that seems very repe... |
I have a bucket with several csv files at differing paths. The problem is that I want to update these csv files transactionally. The s3 bucket should represent the "latest" consistent set of data, and if any update to one of the s3 paths fails, then no update should happen. My s3 bucket for example would look like this... |
I am starting to work on Core Data applications with SwiftUI. I have a view that looks like this:
struct ContentView: View {
@FetchRequest(sortDescriptors: []) private var todoItems: FetchedResults<TodoItem>
enter code here
var body: some View {
List(todoItems) { todoItem in
Text(todoI... |
In MDN article on WeakSets, an example is given for using weak sets to avoid infinite recursion on circular references:
// Execute a callback on everything stored inside an object
function execRecursively(fn, subject, _refs = new WeakSet()) {
// Avoid infinite recursion
if (_refs.has(subject)) {
return;
}
/... |
Consider Mastodon as an example - basically open source Twitter. Tweets can be up to 500 characters long. Of course, since it's open source, you can modify it to allow longer tweets. Unmodified Mastodon can connect to other copies of Mastodon, including modified ones. Mastodon will accept long tweets from other servers... |
We see a lot of 3D configurator web applications on the web and even other type of configurators in embedded systems, such as LED Totem displays. From real time car configurators which every major car brand has on their website, to retail and marketing content configurators.
I always wondered, especially watching the r... |
I am trying to build a travian-like web browser game (static strategy game). I am currently working on my tables and data model. I don't have much experience with relational databases and I am wondering if I am not doing to much normalization.
So in this game, everything is about resources, there are 4 different types ... |
I want to build an app with a SPA (Angular) frontend and a REST API (Spring Boot) backend.
I want a modern account system for this app: users log in through OpenID Connect, using either a social login like Facebook or Google or a custom account with us (achieved through the use of an OAuth authorization server like Key... |
I just happened to stumble across the following question on stack overflow:
In gatomic.c of glib there are several function declarations that look like this:
gboolean
(g_atomic_int_compare_and_exchange_full) (gint *atomic,
gint oldval,
... |
What is the best way to store a recursive data structure in a program? (in C++)
I'm reading data from file, and want to keep it in memory while I validate the data and the user can manipulate it. It will then be written back to file.
I have a many values I wish to store, and each value can be a string, List (== vector,... |
I recently started trying to implement a monte carlo tree search based algorithm for playing cops and robber.
The game is based on the cops and robber game and is played on an arbitrary graph (not multigraph). There are n cops and one robber. The cops try to catch the robber by moving all at once per round on the graph... |
In a test, asserting if a simple method throws an exception under a certain circumstance, is such a test considered a unit or integration test when the exception object thrown is from the standard library of the programming language?
|
I am working with a library that is somewhat poorly written. In order to function, it requires several global variables to be declared and sometimes even maintained by my own code. I really don't like having to put a whole list of global variables at the start of my main file, and even less also having to extern the... |
I have a service (S1) that is deployed on kubernetes having multiple replicas (pods).
S1 requires some data from database (Cosmos Cassandra Api) for calculation.
This data is constantly updated by another service (S2).
There is a scheduler(@Scheduled) written in S1 codebase to fetch data from DB and keep it in memory (... |
Background
I have an authentication microservice that handles the user authentication and returns 2 JWT cookies (access_token and refresh_token).
I want to incorporate an API gateway that does the JWS validation on only the access token that is sent in the cookies.
The concerns
Most API gateways do not support cookie v... |
My application follows Clean Architecture wherein the Application Layer wraps the Domain Layer. I try to adhere to DDD more-so as a "guiding light" than a strict rulebook.
Within the Domain Layer, Repository contracts are defined as interfaces. Those are implemented in the Infrastructure layer with various technologies... |
I apologize in advance for a long-read question, but i'm hardly stuck here and don`t how to ask for help using fewer words.
I need to implement a middleware service which should be placed between two big systems:
First - Asterisk virtual telephony station;
Second - our company enterprise core.
Enterprise core consist f... |
I have a CouponReservationService in an e-commerce project.
It is called when a coupon is reserved to be applied to a basket. It checks that whether the coupons are already reserved. If they are reserved then throws an exception to prevent re-usage. If not then reserves them and allows to be applied.
Currently the rese... |
I have been researching and trying to find the oldest possible implementation of the wildcards and how the asterisk * became the (almost) global standard when it come to represent a wildcard character.
There's many languages that use it that it's actually hard to find which used it first.
The Oldest possible language t... |
This is more of a philosophical question.
I have recently started working on a new team and I see here a pressure on developers to fix bugs in their own code. Whenever a bug is found in a feature, the person who coded the feature is assigned that bug.
As a result, I see a lot of anti-patterns in the code and faulty ass... |
Bridge design pattern is something which is very confusing and GOF does not do justice with beginners in the definition.
I was asked in my current organisation to add one more dimension to our class and use Bridge pattern for it, knowing nothing about it I went through some blogs and have implemented the same for our c... |
I am working with a system that connects a number of voltage reference devices to a measurement device, it does this by "setting a relay".
When defining the name of this function I have a feeling that SetRelay conveys the idea of setting some property of the software object rather than setting the physical relay to the... |
I had an idea for a piece of software using .NET C# as technology.
Basically, in my idea Im thinking of using reflection to do the mapping between a class to another class using interactivity with a user.
About the interactivity right now Im just using console writeline and readline, but in future it can also be someth... |
There are tools like dependabot or greenkeeper for npm and others for other languages. Now at first glance they improve security by keeping open source dependencies up-to-date. But I am wondering, do the benefits outweigh the risk of a hostile party taking over or sneaking in a seemingly harmless commit, which will the... |
I recently finished a large merge with many complex conflicts that needed to be resolved. The branches had been separate from one another for several months while different teams contributed to each branch. Ideally the two branches would have been kept in sync with one another, but that did not happen in this case fo... |
My problem is the following: inside a method I'm creating an object like this:
MyObject* myObject = [MyObject new];
Then I want it to perform an asynchronous task like this:
[myObject doSomethingAsyncWithCompletion:^{
//do something else upon completion
}];
This brings me to a dilemma of how to retain this objec... |
I'm currently scratching my and my colleagues head about whether and how we could test SyncService::syncFoo in any meaningful way
that does not involve basically recreating the whole call tree as mocks.
Edit: It is not a microservice its a Service Class within one project - there was some confusion in the answers/comme... |
What would the appropriate design pattern to avoid deadlock when several functions use the same mutex ?
It is quite easy to forget what method uses the lock and so it happens that you call a function that do a mutex.Lock() inside a function that already locked the mutex --> deadlock.
For example in the following code, ... |
I have two microservices, USERS and PRODUCTS, the second one creates objects referred to first one so it needs first to check that exists
First I though in a redis cache, but then I realize that for other cases I'll need to communicate with kafka, for example for payment microservices where requires fire and forget. Th... |
I was looking at an SQL query recently and found what I think is likely a bug. It was related to case statements on inequalities. I was trying to replace it with a min/max type alternate and when testing, I was getting different results. Here's a simplfied example of the SQL that I was trying to simplify:
CASE A > B... |
Asume these two bounded contexts:
Book Management: manages the creation of books and its attributes:
Book(id, name, author, summary, ISBN, length, cover photo)
Book Order: creates orders related to books.
Order(orderId, List<Book>, deliveryDate, status, etc.)
The Book Order context has an independent web applicatio... |
Lets say that a enum exists:
public enum SomeEnum
{
FirstValue,
SecondValue
}
It's use is spread through the code and all sort of wonderful logic hangs off it.
If we now add another entry (ThirdValue?), we'd have to find all the places in the code that make use of it and update.
Either that or run the risk of ... |
According to Wikipedia, "an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, which is to say if it has any observable effect other than its primary effect of returning a value to the invoker of the operation."
This is the most use... |
So I have this problem where a specific ValuesA enum value is to be mapped to a respective ValuesB enum value, The trick is there can be multiple ValuesA mapping to a single ValuesB enum.
So for the following example:
I have randomly chosen a max range of 3 ValuesA enum values mapping to a single ValuesB enum value.
E... |
I'm building an HTTP server in C using epoll and pthread. The idea is to have an event loop in the main thread monitoring file descriptor and a thread pool to handle computationally-expensive operations.
What I'm struggling is that what type of operation should be done by an event loop and by a thread pool. Here is wha... |
How to apply clean architecture concepts in a software that depends on External APIs.
Example:
A business that offers some kind of subscription to its users.
Its convinient to store some subscription data and how its related with the users inside our database.
The Subscription use case is responsible to receive data fr... |
I am using the Flyweight pattern to cache and reuse objects of the different classes. For example, I have a Shape interface class and multiple types of Shapes implementing the methods from the interface. I also have a factory class that has the cache of object types and object as key value.
As you can see, there is a D... |
I am currently working on implementing the Clean Architecture pattern using Entity Framework. However, I've encountered an issue related to the design of my Domain project. In this project, I need to define a "Wallets" table that should have a relationship with the "User" entity from the Identity project. Additionally,... |
Lately I've been surveying the programming language landscape and one of the languages I looked at was Pharo, a modern Smalltalk.
Programming using a living system that runs in a virtual machine seems like overkill to me. I also don't like the fact that programs in Smalltalk cannot be fully specified using human-readab... |
When and Service Oriented Architecture (SOA) is designed, and the ESB is changed to multiple independent service busses that talk to each other (pub/sub), does the architecture cease to be SOA? Is it then a blend between Microservices and SOA? Full Microservice?
SOA has "bounded contexts" it seems to me, though I usu... |
I'm looking for some best practices for readability (and clean code in general) for naming modules/classes within more extensive projects. More specifically, is it reasonable to add the package's name to the module/class name?
For example, which of the following two structures is preferable?
|-- my_application
| |-- ... |
I'm trying to implement the MVVM-pattern in a new WPF-application.
I'm using the MVVM Community Toolkit to reduce boilerplate code that comes with the pattern.
In my application, I'd like to have a MainWindow that shows a list of records. Additionally, I'd like to have another Window that acts like an "import-wizard".
... |
I am having a bit of problem trying to find the correct place for business logic. The project I am working on isn't huge, but is not small either and has a very considerable importance in my company. That said, I'd like to know how to better organize my business logic. First an example of how things are today.
The meth... |
Is having a separate read only and write only data store a core part of CQRS, or does it still make sense in some scenarios to do CQRS with a single data store?
Asking because a coworker is using CQRS terminology in a project. Whether or not he's actually using the pattern I can't say because I'm not familiar enough wi... |
The problem I noticed is that I wrote a function called filterX which removed any X from a list. Then another engineer came along and wrote a filterY function which kept only the instances of Y in the list. Then it hit me that an "air filter" keeps the "air" while a "noise filter" removes the "noise". So essentially th... |
I have a simple product consisting of 3 apps - Android mobile app in Google Play, backend API and backend administration website.
The API is connected to various external services but this question is specifically about Google Play's (GP) in-app billing system with in-app products. My API can manage the GP's in-app pro... |
Although I love Rust's enums (and the idea of making illegal states unrepresentable), I'm struggling to represent (ironic, yes) them in databases like PostgreSQL when the variants have data associated with them.
Example problem
Suppose we have something like this:
enum PetKind {
Dog,
Cat,
Bird { can_fly: bo... |
I've been interested in following what other successful libraries are doing with their nuget packages. Unfortunately, I can't seem to find any materials to read online and I don't even know what to search for.
What I'm referring to is how a nuget package can be broken down into something like this:
CompanyName
Company... |
When creating a web application that will allow users to upload images and mark them as private, should those images be protected by authentication and authorization mechanisms against access by other users?
The answer seems like an obvious "YES". However, this does not seem to be the general practice. I have played wi... |
I maintain a relational database of sorts, and occasionally a feature request requires a schema change (eg. add a new column, etc...).
However, a number of "services" consume this data. It's not obvious what will break if data change happens.
What are some good strategies to test for these changes and gain confidence w... |
In my company, all of the projects use at least some kind of global state library like Redux and MobX.
However, the actual usage is limited to storing fetched data, and it lacks any caching logic or mechanism. It's merely used to store the method for fetching data and the property for the fetched data.
Personally, I fi... |
I have a ASP.NET Core backend (with Azure Service Bus) and a Blazor Server frontend.
The purpose of the backend and the frontend is to trigger manual and automatic pushing of single data points (hereafter called the "data pushing process") to 2 different external systems (two different, unrelated APIs, that I don't con... |
For example, I know in c++, I can use
myString=="abc"
to check if 2 strings are equal. However, in Java, it is comparing if 2 objects are the same object. Also in other language, for example, javascript, I should use myString==="abc" instead.
In my current environment, I may switch between c++ and Java frequently, and... |
In Common Lisp, we have to use the let form to declare a new lexically-scoped variable. This means that the code either looks like that written in C89 (all variables declared on top of scope), or acquires unreadably deep nesting. let* is somewhat useful, but is not always applicable.
Scheme 'solves' this problem by hav... |
I'm designing a file sending system from a server to many remote clients, around 5000; each file has only one recipient client. Files rarely exceed 10MB.
The server is published on the internet, the clients access the internet but cannot be reached from the outside.
I'm evaluating two solutions.
Expose a WebApi on the... |
What are the performance implications of using multiple threads versus single-threaded asynchronous programming in Python 3.9?
I've been working with Python for quite a while and I'm familiar with both multi-threading and asynchronous programming (async/await). Recently, I've been optimizing a network-bound application... |
I create Hexagonal Architecture based software with TypeScript or C#. The heart of Hexagonal Architecture is the Domain Model.
For example, for a user of application y, the domain model might look like this:
// typescript
export interface UserEntity {
name: string;
email: string;
email: string;
someFunction(ar... |
I frequently use the concept of Active Objects (https://www.state-machine.com/active-object) combined with state machines when designing code. The key idea behind these is that only "events" are fed into (and out of) an object and state machines "react to" these events. This leads to a very different type of design f... |
(updated)
We have a read-only REST endpoint that performs a somewhat “expensive“ but transient request. Without client needing to poll, we need a mechanism for the server to avoid unnecessary processing whenever “similar” but not yet cached requests come it at the same time. What existing technologies & designs can rob... |
I've built a matchmaking system where two of the classes look like this:
I know that it actually looks like an inheritance, but in the code it doesn't extend to the PlayerInMatchmaking and the program is completed and already tested (so I prefer to not change anything). Can I write it as inheritance? If not, then what... |
I am preparing a software package for internal consumption in my organization. It will be published on our internal non-public npm feed.
The used technology (npm) requires me to adhere to semantic versioning by format, though I would also like to adhere to it by idea, which is what this question aims at.
The content of... |
I very much want my code to be const correct and I'm struggling to get the following case right.
Say we have a function F that takes a data structure D and computes an auxiliary data structure D'. F does not mutate D, but the returned data structure D' holds non-const pointers to elements in D.
D could be a directed gr... |
This question may get closed quickly, but I'll appreciate any advice I can get and all the resources I can find online about this topic aren't quite relevant to my case.
I am a Math PhD student doing an internship that requires me to do a lot of machine learning. From my background, the algorithms and statistics are re... |
I'm working on the documentation of software management system. That system can be linked with an e-commerce website to get financial data directly. For example when a transaction will be made it will automatically get updated in our system.
I want to ask if I need to include Database as actor in use case diagram?
|
I have to create a system to interview people on a few topics where they have to answer both objective and discursive questions, where questions may change between interviews. I structured the database in the following manner:
Interview is a table with the user's e-mail and timestamps.
Objective/Discursive Answers fie... |
We have some services (consider 10, some of them already exist and some are yet to come). All of these services have a common part where they keep track of what's being changed, and these so-called "logs" are shown to users, and the persisting/searching pattern is also common in between all of them (searching might be ... |
I am writing tests TDD-style for a cryptography package containing encryption and decryption methods. I test my methods with various kinds of inputs, including multiline strings, mixed case, calling encrypt on decrypt, and mixed case of keys.
@Test
void testConversionLower() {
String originalMessage = "... |
I mostly write mobile apps so this is definitely coming from that perspective, but I think it applies for most UI development.
Suppose I have a UI with the following pattern:
I want to have some user interaction in one part of the UI, and another part of the UI that reacts to it. For instance, the user sets their prof... |
We have recently completed the development of a large system (150,000 lines of code more or less) which was developed from an HLD. Our stakeholders want to take the HLD and compare it with the source code. Is this a common practise? What is the goal of the comparison?
|
"In my company, we have this distributed system over Kubernetes. Some microservices are shared among all customers, and others are up to them to upgrade. This system has to interact with A LOT of customer's services (VPNs, private APIs, databases, log aggregators, etc.), and each customer can have wildly different envi... |
I am wanting to enhance a system to execute various background tasks (primarily data importation). In order to provide data for support, analysis and job status generally, I had been thinking of implementing a related table to record task updates e.g.
datetime message
10:00 Job started: status chang... |
I've been trying to build this (principally desktop, but could eventually be turned into a cloud app) document editor program for a while and have it laid out using the broad principles of the 3-Layer (Data, Model, and UI) and MVC (Model-View-Controller) patterns, and one thing I've often run into is where to best put ... |
Python, Ruby, Rust, Haskell, Kotlin, C#, C++, Perl, MATLAB, SQL, and R all call their respective array predicate checking functions any and all.
Is there any record of why JavaScript's designers decided to deviate from the naming convention other languages have used for these functions since the 90's?
Some Lisp-family ... |
For example, I have an object:
public class Obj{
public int a;
public float b;
public String c;
}
I need to find best "Obj": largest a and then largest b and then longest c:
int bestIndex = 0;
int bestA = 0;
float bestB = 0.0f;
String bestC = "";
for(int i = 0; i < objArray.length; i++){
Obj obj = objA... |
I have a kubernetes deployment which is fielding expensive (but cache-able) requests, let's say a website scraping service (not really) which takes about 15 seconds to scrape a website. In my backend I also have a postgres database running which I can use to cache request data. The a typical pattern of requests to my s... |
I have an existing application using Codeigniter Framework (MVC). I need to implement an integration in the software with the external cash register (e.g., making REST API calls). I need to either make a controller or a model (or both), but I don't fully understand which.
The functions within the class will be doing th... |
I am writing a web application for a simple, multiplayer dice game so the traffic from the client to the server is going to be pretty light and latency tolerant. The client will need real-time updates from the server so I was originally going to implement the game entirely in websockets. However, I've come across desig... |
I'm tasked with developing an application which is going to track what an end user does in a session.
My application doesn't handle user registration or anything related to user. The user management is a different bounded context(a separate micro service in my case.) But my application would need to identify an user fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.