instruction stringlengths 34 36.1k |
|---|
I'm stuck with a problem, where I don't know how to model interfaces that are provided by different IPC frameworks.
Let's say, there is a camera component and two arbitrary components C1 and C2. The camera has an interface for retrieving health data like temperature, errors and so on and an interface for retrieving the... |
For instance, if I'm modeling a book collection and I want to be able to represent sets of books that come together (like an encyclopedia series), the sets may share a lot of properties that individual books would also have (author, publication date, title, etc.). In terms of naming the classes in an OOP context, would... |
What's the recommended design for an endpoint that accepts a nested resource as the following:
POST /account
{
"name": "Project John Doe",
"description": "Description of the account...",
"type": "corporate",
"relation_number": "PR2022-1509-8",
"contacts": [
{
"firstname": "John"... |
I've read several questions and I couldn't find one specifically similar to mine. I also don't think there's a design pattern for this situation as I think my system is a legacy system and don't fit the "best practices" in many parts of it.
I'm rewriting a legacy feature from a 1990's system to a "new" system in .net, ... |
Users are allowed to post on our website and we have started to get some spam. We have a background process that removes most of them after a few minutes, but are integrating a better solution that blocks on ingestion. This way they never make it to the site.
My concern is that if we give them a big “we’ve detected spa... |
We have several medium to large software projects targeting different platforms (arm32/64 and x86/amd64 on Linux and Windows) with a lot of duplicated code in them, since every project has its own split(string, delimiter), find_files(regex/pattern), and stuff like that.
Because of that we're fixing identical bugs over ... |
Semver specifies to update the major version on a backwards incompatible change. Would modifying the behavior for the hash function of a custom type fall under this category?
I asked a couple friends, and they mostly generally agreed that it shouldn't. For using data structures like a hashmap or hashset, they behavior ... |
For example, which term completes the sentence "p has 5 ____" in order to describe a situation like int *****p?
|
My company has a huge C++/C# software system composed of 1800 binaries. The technology range goes from old school native C++ Static Libs, C++/MFC, C++/CLI, up to .NET Framework, .NET Core 3.1, .NET 6/8/etc. Almost all possible Visual Studio project types within this technology range exist in the software.
We struggle t... |
I am trying to imagine a website/system where only 1 copy of a file is ever stored, but multiple users get their own custom link to the file, and it uses the CDN features. For this question we can assume we are using S3 and CloudFront or other AWS CDN features, but I am probably going to use Google Cloud Storage instea... |
We have product X which has the following semver versions: 1.0.0, 1.1.0, 1.2.0, ..., 1.10.0.
In version 1.5.0, we introduced a feature which changes the way the application is consumed in a big way. Eventhough the change is backwards compatible (which means a minor bump would be appropriate), we didn't realise at the t... |
The most of the database management systems use B-tree as a data structure for increasing the performance.
Let's imagine that we have a table users with the following columns: id (int), name (string), email (string), password (string), age (int). We want to select only ones that meet the condition: (name.contains("Bob"... |
I often come across this dilemma in my own code and wondered if there is a term for this and if there is a single solution to it. Let me illustrate it with a pseudocode example of making a table from some book info:
pure option
make_table(bi, ab, pd): [p]
t = make_table_from_book_info(bi) [p]
t = add_author_bi... |
I''m working on a C# library where the API provides several public interfaces and a single concrete factory class (itself an interface implementation). This factory provides implementations of the various interfaces. Other than the factory, none of the actual implementations are available to the user.
As is the natur... |
I'm creating a service for creating web tools. The tool is a generated web page with some JS engine. The user can interact with the JS engine through the user interface. The user interface can be either ready-made or custom.
The idea of using a custom user interface is dangerous. This approach creates possible securi... |
I'm engineering architecture of a new web based software.
I've never worked on high-scale softwares before and I'm reading a lot about it.
To increase client-side speed and reduce load on servers, and also enabling server-to-client communication, I decided to use WebSockets.
To process request from clients, I always re... |
I have several services and each of these services has interfaces for each. I need to add a shared execution strategy here. By designating two classes with the same inheritance relationship as primary and secondary, one should be executed according to a branch.
Example of the services:
interface FirstService {
abs... |
I have a text file which is evolving and thus, difficult to manage. Hence, I am going to rewrite the code from scratch. Since, only few parts of the txt file change with a newer version, from the answers here, I understand that I should prefer a template design pattern rather than a strategy design pattern.
Below is an... |
I know almost nothing about threads, synchronization, ...
That being said, I am working on a record handler, that hits Excel sheet to pull/push data. There exist, in my code base, a BaseRecordHandler, which use the entire spreadsheet to read from/write to. The game plan with it is as follows:
create singleton instance... |
Subj - how could I allow\disallow actions in my system based on the state of another external system (I have access to it's state via the shared DB table)? I can get the state of another system almost immediately, another system is like a state machine with some states like 'running', 'maintenance', 'initializing' etc.... |
I am using this DTO class to pass object between web application layers
public class CreateProgressDTO
{
public int Total { get; set; }
public int Created { get; set; }
public decimal Progress { get; set; }
}
In many places I had to do the following:
var createdNone = new CreateProgressDTO()
{
Total = ... |
HTML rendering and javascript engines are very optimized, so why do they feel slow on smartphones?
It seems that HTML's low performance justified the creation of mobiles "apps" which are more responsive, but also did not allow developers to just do things in HTML.
It seems that websites are generally too heavy/cluttere... |
I need to compare and synchronize two tree data structures.
I have Tree A (the "Reference Tree") and Tree B (the "Target Tree"). I need to bring the Target Tree into compliance with the Reference Tree. I need to find differences -- additions and deletions, including those that result in new descendants or branches -- a... |
I am currently making a newsletter website that will send you a email with the top ten manga for that week. Currently I have a web scraper that retrieves the top ten along with descriptions and other fun stuff. It then puts that into a pandas table which I was hoping to use along with a Heroku hosted Postgres database.... |
I am building a wrapper for a library that requires little complex logic. The whole project is 8 builder classes, 4 classes for doing some pre-processing, and a couple visitor classes. Essentially I am just building wrapper classes around a third party library's objects. I was curious whether in a situation like this i... |
So I've got a simple object recognition app in iOS. I am trying to create an Interface-Adapter for the machine learning / computer vision like this:
protocol MachineLearningInterface {
func detectObject(from sampleBuffer: CMSampleBuffer) -> Observable<DetectedObjectEntity>
}
// Either Apple or Google
class AppleMac... |
I'm working on a Desktop App in C# that communicates with a Java backend hosted AWS.
I want to deploy on multiple instances and use an Application Load Balancer with sticky sessions but as Far as I know it is based on cookies to route the request.
So far I can only think on 2 solutions :
Handle cookies on my Desktop A... |
At first glance, these seem equivalent. If one has the right visibility, one can access a global variable or a class variable from anywhere in the program; There is only one, shared copy of them. So why would a software engineer choose one over the other?
Considerations could assume a language like Python, with no priv... |
We have divided our app into vertical slices, by feature, each of which contains domain/data/application/ui layers which has increased cohesion. However there is still some coupling because feature B might use value objects (or things associated with the value objects) from other features. For the sake of the example l... |
Most of the information that I can find online is about how to do basic dependency injection in the common flows. eg one DI container where services are registered.
For a project we are writing a library that comes with internal services and public services. The public services are the ones providing methods that can b... |
I am thinking in a common orders and order lines example. The order has a state and depends on the state, I can do some actions or not.
I guess that a good option for that it is to use the state pattern. If I am not wrong, with this pattern, I should to have one action for each possible state to change the order from o... |
I'm interested in finding a text distance (or string similarity) algorithm which computes a greater distance (or lower similarity) when characters are further apart.
For example, I want the distance between abc and abz to be greater than the distance between abc and abd.
It would be easy to compute a text distance like... |
My application contains webhook handlers that should execute many actions when the event happens. Given CUSTOMER_REGISTERED event this is what happens in pseudocode:
function WebhookHandler(EVENT) {
const selectedStrategy = selectStrategyBasedOn(EVENT)
const result = executeStrategy(strategy);
...
}
function execute... |
Let's say we have the following business requirements:
We have a list of dishes. They have a name and a list of ingredients. The restaurant owner always wants to have a dish (and only one) marked as the "main" dish.
Let's suppose we are using an OOP approach, and we have two possible designs (I'm using python but it ... |
So, recently I have been looking into developing apps. I joined a school group who wanted to develop an app, problem being that I had an Android phone and my friends all had Apple phones. I know of Unity, but I was wondering if there might be a better way to develop apps for Android and Apple simultaneously. While havi... |
Background:
I'm splitting a monolithic multi-tenant chat bot builder application.
Each customer registers an API token for a third party API which their bot will run on such as slack/telegram/discord. They then use our service to code the "brains" behind the bots functionality.
I have identified a number of microservic... |
I'm seeing two ways of orchestrating NServiceBus sagas. I'm not familiar with it so I'm trying to understand if they are just two alternative ways of doing the same thing or if I should follow one or the other.
The scenario is a saga that is going to perform three steps - each of which is some sort of complex behavior.... |
Talking about gateways from the Clean Architecture, it is required to distinguish:
The interfaces
The implementation of these interfaces
The TypeScript example:
// === Interface ======================================
interface UsersGateway {
retrieveSelection: (requiestParameters: UsersGateway.SelectionRetireving... |
Currently I don't understand the Use case concept enough good - too much abstract definitions but no particular examples. The section Use Cases of Chapter 20 Business Rules does not including any code or at least UML example.
The current question is discussing around below paragraph:
A use case is an object. It has on... |
I have an ERP-style system that needs to allow users to orchestrate an Entity.action() on a variety of objects that implement the Entity interface, at different datetimes. Calling action() would change the Entity state.
What design pattern/architecture would be appropriate to allow users to store and manipulate a logic... |
I've been using Git and GitFlow for quite a few years now, but this is still confusing me.
Let's say I open branch release/1.1.1 to let the stakeholders test their application.
While they're testing devs complete 2 new features and merge them on develop.
Meanwhile stakeholders ask for 2 small fixes on release/1.1.1, de... |
I'm trying to find a good way to implement state transitions for a job posting. This is just an experiment in trying to write better code.
You can find the code and a diagram in this repo.
The main problem I have is how can I write the code in such a way that there are as few as possible exceptions thrown. For example,... |
In microservice architecture, let's say I have 4 services that will need file upload/download feature, I have two options for this:
I can create another new service(5th) to expose an file
upload/download API.
But when it comes file download authorization, the download privilege actually depends on the other 4 service... |
Is it a good idea to mark a function const from clean code perspective if it change other objects' states? I'd like to know what is the experience with this or is it considered a bad practice for any reasons?
|
I have the request to integrate my Python server application (Flask/waitress) with Kafka.
That means that it should frequently poll a certain Kafka topic (on the order of minutes) and process all new events.
As the application is deployed in the cloud, I am looking for a scalable solution so that different events could... |
I have a project in which I have to manage projects, invoices and orders to providers. So I think that I can define three bounded context.
First bounded context: Projects.
Second bounded context: Invoices.
Third bounded context: Orders to providers.
Well, my doubt is how to the invoices of a project, because they are d... |
I have two versions of an API with similar but slightly different response structure. We are currently using V1 of the API and will gradually move to V2 soon. The switch has to done using a feature flag that gets triggered remotely.
Our class look like this,
@RequiredArgsConstructor
class ServiceA {
private final ... |
Sorry, I would have left a comment on the other question, but I don't have enough reputation.
I have the same problem as in this question:
How to specify many ids and their variable name in a REST API request?
I have a big list of 800+ employees. (I have to show them all at once. It's required by the customer.)
The use... |
We have a largeish .NET Core project which uses Mediatr and EF Core. Many of the queries look something like:
public class GetSomeInformation : IRequest<string>
{
public int DocumentId { get; set; }
}
and we load the entities with AsNoTracking to avoid issues with attaching duplicate entities if we need to update ... |
I am trying to design in DDD the management of orders to a privider.
The order has to have the information of the provider to which i will order the items. Later I will add lines to the order. This lines will need to have information of the provider, but different than the data that I need for the provider of the order... |
I am trying to create a simple demonstration of using 'parallel LINQ' (PLINQ). I have two versions of my task, in C#:
var result = Enumerable.Range(1,1000000).Where(x => IsPrime(x)).ToList();
var result = Enumerable.Range(1,1000000).AsParallel().Where(x => IsPrime(x)).ToList();
and use a System.Diagnostics.Sto... |
C++ and Python are the only two languages I know supporting multiple Inheritance. Other object oriented languages I have seen like Java and Ruby do not support multiple inheritance. Even the front-end scripting languages do not support multiple inheritance.
According to Wikipedia,
Multiple inheritance allows programme... |
We know the «Gangs of Four (GoF) Design Patterns» have 23 Design Patterns.
But I wonder: are design patterns limited to these 23 or do we have more? And what would be the sources for other design patterns?
|
Given a (Django) web application following the model-template-view model, when returning a template based on an object should if-else logic be in the view or the template?
The API endpoint (view) gets a request to display a template based on an object (model). Some parts of the template are conditional on properties of... |
Our travel industry client, operating across three continents and several countries, wants to standardize the process of choosing travel packages, air routes, hotels, and hundreds of other travel options. Today, local travel agencies decide themselves what they want to offer or not. The idea is to let them make decisio... |
floating point representations##
exponent == 7 bits ,mantissa == 8 bits
2044 = 0 1001001 11111111
2045.5 = 0 1001001 11111111
why is this happening?? what is the error? Is anything wrong with the conversion?
|
In the book Operating System Concepts,
In the summary it states:
A monolithic operating system has no structure; all functionality is provided in a single, static binary file that runs in a single address space.
Although such systems are difficult to modify, their primary benefit is
efficiency.
A layered operating sys... |
I have a job system that has two different types of dependencies per-job:
Jobs can rely on other jobs to be completed first, but this is optional
Jobs have read/write dependencies (shared/exclusive) that are used to restrict which jobs run at the same time. This is currently represented as a series of type hashes for ... |
I have a number of non-nested if statements that look like this:
if (!bytes[nameof(PropertyVersion.Price)].SequenceEqual(dbBytes[nameof(PropertyVersion.Price)])) changes += $"Price {TextHelper.AssessValueIncreasedOrDecreased(dbPropertyVersion.Price, propertyVersion.Price)} from: £{dbPropertyVersion.Price:N0}. ";
if (!b... |
As a design priciple I was taught:
Programe para una interfaz, no para una implementación. Es decir, no se deben declarar las variables con el tipo de los herederos sino con el tipo de los supertipos.
Translated:
Code for an interface, not for an implementation. That is to say, variables should not be declared with ... |
I'm sorry if the title is confusing, I don't know if what I am describing has a proper name so let me describe...
I have an algorithm which contains quite a bit of nested if/else if/else logic for detailed analysis of input data from the database. This is business logic that's inherently quite convoluted so there are o... |
I’m using a hexagonal/clean/ports-and-adapter architecture. For the sake of simplicity, I’ll only talk about domain and infrastructure here, where the infrastructure has dependencies on the domain but the domain is unaware of the infrastructure.
My application (infrastructure) receives events. The infrastructure layer ... |
I am seeing this example in the Microsoft documentation:
Here we can see how OrderItem has a reference to the ID of the product, it is the first option that sure people uses to think, me too.
But I was thinking about this and I was thinking, why isn't OrderItem a value object?
If I use the ID of the product, I have th... |
I'm reading OO DDD slides from Robert Brautigam, who is quite active here so I hope he can personally answer as I quite agree with his personal understanding of DDD, and approach of having a more object oriented approach instead of a service one.
In our apps we have an awful lot of this:
class OrderService {
OrderRe... |
I'm new to queuing and looking into options that could be done operationally. I'm sorry if I have any conceptual misunderstandings related to queuing.
I watched this video where the presenter made a point that one benefit of SQS over RabbitMQ was that if you ever had to do maintenance on your RabbitMQ server that you c... |
I'm working on an app that will focus on P2P communication via WebRTC. Part of the app's functionality is discovering other devices in an x mile radius and then being able to initiate communication with them. The most straightforward way to do this is to send the raw locations of all the clients to a server and then re... |
How many dependencies does a unit test have (that are not mocked)?
My understanding is that a true "unit test" has zero dependencies, with all of them mocked (or none in the first place; pure functions.) (Unit tests are excellent for pure code, but in a real application most code is not that pure. They work great for s... |
As has been covered to the point of parody, heavily object-oriented languages, such as C# or Java, tend to lack the feature of having functions as a primitive type. You can argue about whether or not their functions are first class, but the pattern is always that you cannot reference a function on its own; It must alwa... |
I have products saved in my database that my system fetches with the following structure:
public class OriginalProduct {
public string Id { get; set; }
public string Name { get;set; }
}
I need to enrich the product with additional fields like a price, stock level, images, description etc. These are all fetched f... |
I'm sorry if I'm using any wrong terminology here.
I'm trying to design an architecture where there can be big and small tasks (e.g. processing big or small images). Big tasks can only be handled by big boxes while small tasks can be handled by either big or small boxes. The big tasks can finish while there are still s... |
I am stuck with this particular problem. To give context to the problem, I am developing a mobile app which helps with loading dangerous goods onto a truck. Ignore the size and weight of the dangerous goods.
Some dangerous goods cannot be loaded onto a truck unless one of the goods is in a specific type of box.
For exa... |
I am reading Tanenbaum's Modern Operating Systems. I want to understand a particular concept regarding processes and blocking system calls, specifically with regards to I/O. I assume threads might complicate the discussion somewhat, so please assume that I am asking about single-threaded processes only.
The book states... |
I am working in a database that has a hierarchy of Companies (From location-level all the way up to Top-level parent company). I am designing a system within that to provide a "subscription" mechanism that has implied inheritance. So for instance, Let's say you have Parent company A that has a subscription to service S... |
I have a pretty simple domain model. Basically users, companies and groups. A user can add members to a group and remove them. But the user can only do that for his own company.
Where do I put the check that the user is only adding or removing users from his own company?
I've got the Group Aggregate which has 2 methods... |
I was trying to use the state pattern in a DDD aggregate, but I was thinking in the following alternative.
In sumary, the state pattern controls what actions can be done in each state. This makes to create one class of each possible state and implement it. So if I want to add a new state I have to modify the code.
I wa... |
NOTE: This question is reposted from SO because it violates community guidelines for being opinion-based.
I have two classes that are similar in nature but they have different functional signatures. I am considering between having two interfaces vs having one. Let me illustrate:
Approach 1: two interfaces
public interf... |
I'm a junior web developer. My current work is on a form-based server side web application. It was set up using jQuery. I'm now the primary person working on it. In a previous job, which was more front-end-centric, they decided to move away from jQuery. It was not needed anymore.* I heard it elsewhere as well. But I so... |
I've found this pattern useful, and am trying to classify or name it.
Basically, that:
A task should be performed by different strategies, depending on the context.
Each concrete strategy implements a common interface.
BUT... caller doesn't choose the strategy.
Instead there's a priority-ordered list of the available ... |
This seems pretty newby question but I still can't find a answer I'm ok with.
I'm doing a microservice and decided to have a Message as an aggregate root. This Message represents a kind of announcement and incapsulates distribution rules.
From the other side I have a MessageHistory agg root to track creates\updates whi... |
In a typical DDD layered architecture (application, domain & infrastructure layers) you'd generally declare interfaces in the domain/application layers and implement infrastructure-dependent (e.g. file system, network, third-party libs, etc.) implementations in the infrastructure layer.
For instance, a ClientRepository... |
I'm trying to understand the size of a micro service.
Fake situation: Data is read 1,000,000 times for every write. So when you scale out you generally only care about scaling out for the 'GET' requests, not the POSTs. Should POST and GET be separate deployable applications?
PRO: Spinning up a 'GET' box would be faster... |
I was thinking in the common example orders, that can be in different statates. From create to pending to accept, accepted, sent... and so on.
But the order has data too, for example the client, the address to deliver, coments and another information that can be modified depending on the state. For example, the address... |
On Stack Overflow I frequently see questions with code in the following style:
function funcName(parameter) {
let variable = parameter;
// rest of function uses variable rather than parameter
}
Is this just some cargo-cult practice that some programming teachers pass on, or are there coding style guidelines that a... |
I am faced with an interesting OOD problem: I have an interface with 3 methods:
interface TestInterface {
String action1();
String action2();
String action3();
}
and 3 classes that implement this interface, so I have a very simple code:
TestInterface testInt;
if(something) {
testInt = createObject1();
} ... |
What are the best practices that I can follow that can simplify or help abstract out entity modeling when there are many similar but different entities?
I have a large game system with different types of accounts representing an end user, but they are all distinct & isolated.
To name a few,
The system has a concept of... |
we have a microservice architecture.
There is an API Gateway that acts as entry point for a External System (SAP)
It is clear that SAP should connect with our system using the API Gateway.
But, in the case a microservice (Costs API in the diagram) wants to consume some API inside the external system, it's a good choic... |
As a university student who just have been learning programming for a year. After I learned about the concept of state machine and the pure function in functional programming, I suddenly got an idea about combining them together as a programming style.
Everything is either a state machine or a function.
(So all the va... |
Imagine a simple set up of an API and a 2nd service, where the API pushes some msgs to the message queue and the service pulls them and processes them.
Now, if an error occurs while processing a msg, there's no straightforward way of sending the error upstream to the API, so it can bubble it up to the client.
The firs... |
With interface injection (wikpedia) we have a method to set the dependency on the client as part of an interfase.
public interface ServiceSetter {
public void setService(Service service);
}
Why do we need separate interface for the setter method instead of just having it just in the client class?
|
I'm recently learning the programming language, and I wonder how compilers work when the language itself does not allow recursion, like how the compiler or the runtime checkers makes sure that there is no recursion. I learned that compilers don't need to understand recursion when translating the code, but how does one ... |
I want to make sure I understand the concept referred to by alignment:
Is it just a way of making sure that you never have a non-integer number of words? The wikipedia page says in order for an access to be aligned, the address has to be a multiple of the datum's size (which I interpret as number of words; as in, a 4-w... |
Imagine a queue system with different consumers - some are low cost whist (like 'reserved/spot' instances in the AWS world) others would be high cost.
The system should ensure the messages are processed by the low cost consumers when available, but if they are unable to process a message after a certain time period th... |
I work on a code base which was started by a small team. Over time, more features were added, and the team has grown significantly. Everyone has added functionality here and there. There is a rather central struct which is used to keep track of intermediate results as it is processed through the system. It started out ... |
I have an array of entities which have an id property:
entities: {id: string|null}[] = [];
All items in the array are guaranteed to have id !== null and the array will not exceed 100 items.
Now I may want to find a specific item based on a condition:
const id: string|null = condition ? value : null;
My quesiton is: I... |
In my team we are currently building an API gateway, where the client can authenticate themselves with an API key. Naturally the authentication may also fail, which produces a message in the log.
Should this be logged on the 'error' or on 'info'-level?
I have a couple of arguments for both, but am unsure if there is a ... |
We are rebuilding an on premise application using microservices and are wondering how to implement data autonomy given certain constraints that we are facing:
The application is built around a set of files that it needs to keep in sync with the cloud service. We have very limited bandwidth available, and so we have to ... |
Two developers (front-end and back-end) are working on one User Story, while the front-end is dependent on the work of the back-end. What is the best way to handle this dependency regarding the branches:
The back-end creates a branch, works on that, and the frontend continue to work on the same branch.
The front-end ... |
I started a project awhile back and have made a lot of progress since then. In the beginning I didn't think much about restful architecture and how I'd serve data to the frontend. Now, however, it seems the way I am doing so isn't exactly like other projects I see, so here is my question.
What are the main issues with ... |
I have seen in mainly high level languages, but also in lower level languages, the use of option names as strings to specify one of several fixed options, or as flags, or more generally, code using strings to communicate with other code.
In GTK, for example, g_signal_connect() uses a string as a signal name to specify... |
I made a patch to a programming language run-time to cache the results of hashing a string in the string object, so that it is just retrieved the next time it is required.
However, I'm not convinced there is any worthwhile benefit, and the feature comes at an opportunity cost. Heap objects have only four pointer-sized ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.