Skip to main content

Questions tagged [design-patterns]

A design pattern is a general reusable solution to a commonly occurring problem in software design.

Filter by
Sorted by
Tagged with
1 vote
1 answer
216 views

Suppose I have some Java code such as the following (in this case, the use of the name "interaction" is referring to interacting with an object in a video game): public abstract class ...
micheal65536's user avatar
3 votes
1 answer
2k views

I would like to know more about the Specification Pattern, as it is described in Eric Evan's book "Domain Driven Design". One of the key points Evans makes is that the domain model contains ...
Agah Shamekhi's user avatar
0 votes
1 answer
113 views

I have a (php) program, which must change yearly. This program calculates tax for every year and there are sometime changes in requirements. First, the user fills their incomes, expenses, etc. Then ...
nrob's user avatar
  • 111
1 vote
1 answer
261 views

Consider the following Typescript code: function exampleAction(target: Target, options: ExampleActionOptions) { // ... } export function getExampleAction(options: ExampleActionOptions) { return (...
kaan_atakan's user avatar
1 vote
4 answers
371 views

I am currently looking for a way to encode a list of random numbers most efficently (as in length). To be specific, I have an array of 11 numbers containing each number from 0 to 10. The order will be ...
DK13's user avatar
  • 29
1 vote
1 answer
261 views

I'm refactoring some old code, I have a lot of istanceOf in the business part: if (record instanceof RecordA) { RecordA recordA = (RecordA) record; ...
Accollativo's user avatar
1 vote
2 answers
225 views

I have a Product entity: public class Product { public int Id { get; set; } public string? Name { get; set; } public string? Description { get; set; } [ForeignKey("Brand"...
Subliminal Hash's user avatar
2 votes
2 answers
665 views

So I've been going over some design patterns and I came across this discussion https://stackoverflow.com/questions/43565475/using-lists-instead-of-decorator-pattern I've been thinking that in all ...
crommy's user avatar
  • 129
0 votes
1 answer
161 views

I've got this class: [UsedImplicitly] public class ClassicalKeplerian { public ClassicalKeplerian(Angle argumentOfPeriapsis, Angle inclination, UnitFraction eccentricity, Angle ...
ScottishTapWater's user avatar
-1 votes
1 answer
237 views

I am working on a program to automatically design heater units based on varying client specifications. The process for creating each heater is quite involved and requires multiple optional steps ...
JS Lavertu's user avatar
2 votes
1 answer
161 views

My question is regarding how would the developer know when you add interfaces/protocols to their code and inject them as dependency. Consider an example of BudgetService. protocol ...
john doe's user avatar
  • 141
-1 votes
1 answer
105 views

In one of the project I am working on, I am facing a problem in terms of creating an object with a dependency that sits at a deeper level in the class composition. Following diagram shows the class ...
subtlecode's user avatar
-2 votes
1 answer
130 views

I'm trying to develop a CRUD feature for an ASP.NET app that lets me manage customer information. Each customer can be subscribed to one or more services, and each service can have one or more terms. ...
David's user avatar
  • 1
3 votes
3 answers
673 views

I have seen Martin Fowler using the term "collaborators" as some sort of synonym of "dependencies". Unfortunately, Martin Fowler does not seem to define the term anywhere, so it is ...
Mike Nakis's user avatar
  • 32.8k
0 votes
1 answer
327 views

I've got a file in my includes folder, which is the folder I expose, that isn't used externally and isn't supposed to be used too. When I noticed that and tried to remove it - I noticed that it's ...
RedYoel's user avatar
  • 123
0 votes
2 answers
801 views

Question Background Consider a scenario in which I have two structs. Both consist of three fields for doubles. The only difference is the names used to refer to these fields. The first struct is for ...
Shadow43375's user avatar
1 vote
1 answer
537 views

We're dealing with a lot of "data analysis", basically different sorts of data mangling, aggregations and calculations using Pandas. Usually, the data is time series data. All underlying ...
highviolet's user avatar
0 votes
0 answers
150 views

From what I understand from this answer, it is not possible to use a typeddict and typechecking in a function. So for example, if one has a function: def some_func(some_int: int, some_dict:...
a.t.'s user avatar
  • 225
1 vote
2 answers
110 views

Suppose there is a flow of functions in C++ step1(); step2(); step3(); step4(); step5(); and they interact by adding and modifying data on a data class D (only data, no functions). For example, step1(...
tqw's user avatar
  • 121
0 votes
3 answers
2k views

I have a Material class : public class Material { public string Name { get; private set; } public double Density { get; private set; } public double SpecificHeat { get; private set; } ...
Lionel du Peloux's user avatar
15 votes
6 answers
6k views

I have a simple 2D game which has squares, player (teal) and enemies (red). class Game { List<List<Square>> map; Player player; List<Enemy> enemies; ... My problem is that I ...
MaLa's user avatar
  • 310
2 votes
1 answer
3k views

I'm new to DDD and I trying to create an API using DDD concepts for study purposes. Today, I faced a scenario where I've to create an Application Service to expose a functionality to be cosumed from ...
Gabriel Morishita's user avatar
0 votes
1 answer
190 views

At my company we are revising some backend architecture. I think I have identified a use case where event streaming (for example with Apache Kafka or RabbitMQ) makes sense. Because me (and everyone ...
Puck's user avatar
  • 55
3 votes
1 answer
191 views

What is correct in your opinion regarding the creation and handling of models in an application let's say using MVVM, or even an MVC design pattern? I will try to illustrate the situation I see at my ...
Lucas's user avatar
  • 139
3 votes
2 answers
2k views

I'm building a web application using Laravel. I use the repository pattern as my data layer. Imagine there's some entity like Product and a product can be assigned to a ProductCategory. The Product ...
user2190492's user avatar
1 vote
2 answers
261 views

I'm an applied physics student and currently working on a simulation of the magnetic interactions of multiple protons within a protein. Me having only little experience with programming and almost ...
Meck3l's user avatar
  • 17
3 votes
4 answers
1k views

This is in context of a distributed computing. There is a Service A which owns a database and hosts APIs for updating an entities in this database. As time went by, the service has evolved and we are ...
Sanath Kumar's user avatar
-2 votes
1 answer
82 views

Let’s imagine system like Garmin connect, you run, record your workout and then once you finish workout is uploaded to the system and being analyzed. Based on analysis you can receive badge: for 5 km ...
Snorlax's user avatar
  • 117
1 vote
0 answers
124 views

I need to design an application which makes requests to an external API. External API has a hierarchy of entities: User which contains ListOfItemss which contain Items. I need to get data on all Items ...
Yos's user avatar
  • 167
0 votes
1 answer
168 views

Is there a best-practice pattern I can/should use for this scenario? I need access to some DI services in the OnFinished() method: public class Product { public int Quantity {get;set;} } public ...
mxmissile's user avatar
  • 103
2 votes
3 answers
631 views

The following design emerged from using Azure Durable Functions with lots of fan out, which turned out to not work very well. Our starting point was an Orchestrator with a companion Durable Entity for ...
Thomas Eyde's user avatar
0 votes
1 answer
465 views

I am writing a simple application to apply what I have learned so far in DDD. I have the following mysql tables in my api server Sales Column id pk, int title varchar description varchar Images Column ...
emhsmath's user avatar
0 votes
1 answer
1k views

I have an existing system that inserts books into a library database, and I want to generalize it to include other media. The other media is similar, but not exactly the same, and all media are third ...
Kee's user avatar
  • 13
0 votes
1 answer
528 views

I am trying to tinker with the MVC pattern and I have a problem when trying to design the MVC structure. I need a model for products, however as I need to manage more and different data, I can help ...
Eideann's user avatar
  • 13
3 votes
3 answers
1k views

I've been developing a non-trivial personal application and I thought I'd use CQRS to learn it. The application is very data entry heavy, lots of entities and lots of forms. I find myself constantly ...
David's user avatar
  • 163
0 votes
1 answer
1k views

I'm looking for an elegant way (a design pattern if such exists, not a library) to map two classes that share the same base class, without duplicating the code that maps the properties of the base ...
Joep Geevers's user avatar
2 votes
1 answer
406 views

I would like to have a class, let's say a queue, that can be specialized to its behavior. For example, let them be a SafeQueue (which disables IRQs before any access) and a FastQueue (which doesn't). ...
JD.'s user avatar
  • 131
1 vote
1 answer
4k views

Context Suppose one has a list of algorithms, which each have a multiple run/parameter configurations. Next, one wrote a generic function def get_mdsa_configs(self) -> List[MDSA_config]: that ...
a.t.'s user avatar
  • 225
2 votes
1 answer
1k views

I am writing an application where a user will have a custom config json file. The json is just a dictionary where they define new objects of the exact same type. Here is an example with outfits: '...
Ryan Folks's user avatar
3 votes
2 answers
622 views

Imagine there is a stream of requests for about 500 types of work. There can be say 5 workers in parallel. One type of work should be executed by at most one worker at the same time. The requests for ...
tm1701's user avatar
  • 99
0 votes
0 answers
146 views

Context Suppose there is a e-commerce microservice architecture with the format: In summary, a client will contact the Auth Service / Identity Service to receive a token. It passes the token to the ...
Gianluca Fuoco's user avatar
1 vote
2 answers
2k views

I'm looking for specific software design patterns that can help me understand how versioning of the same entity where the domain logic has changed between the versions, can be solved. The following ...
martin's user avatar
  • 111
0 votes
1 answer
137 views

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 ...
Q-bertsuit's user avatar
1 vote
2 answers
222 views

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 ...
Nishant Chauhan's user avatar
0 votes
1 answer
192 views

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 ...
user21918's user avatar
  • 111
1 vote
1 answer
420 views

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 ...
MrTrick's user avatar
  • 113
0 votes
2 answers
399 views

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 ...
nanotek's user avatar
  • 341
1 vote
1 answer
220 views

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 ...
filur's user avatar
  • 127
-1 votes
3 answers
1k views

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....
Azhari's user avatar
  • 115
6 votes
6 answers
557 views

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 ...
Denis123's user avatar

1
3 4
5
6 7
91