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
0 votes
1 answer
126 views

Separation of concerns: persisting complex types

I have the following module structure: core persistence extension In my core module, I have an interface: Handler. This interface has multiple implementations in the core module as well as extension ...
alturkovic's user avatar
2 votes
1 answer
83 views

How do I structure my functions (and classes?) which interact with my Database/ORM?

So I am working on my first project using SQLite and SQLModel as ORM. Creating and handling the first table in my database was easily structured: A function for each CRUD-Operation. But now I have ...
Jan's user avatar
  • 201
1 vote
2 answers
203 views

How to design fault-tolerant distributed "all-or-nothing" system?

I have a system where Client(C) sends request to Server(S0). S0 then sends the response back to Client that "request received" and closes the connection. C can regularly poll S0 to check on ...
sam's user avatar
  • 23
3 votes
1 answer
79 views

Shell Script Design Patteren: Source a library file VS Call different files?

We discuss about POSIX compliant shell script here. While we are writing more and more shell scripts, we build some helper functions to reuse the codes. We are considering putting a few helper ...
midnite's user avatar
  • 131
0 votes
2 answers
108 views

Appropriate design pattern for providing a default Argparse instance, eliminating boilerplate

I'm using argparse.ArgumentParser extensively; however, it comes with a lot of boilerplate to set up, and this is especially noticeable when you've got more than a few common arguments that probably ...
g_elef's user avatar
  • 19
1 vote
2 answers
158 views

Pattern to transform and cache data from a DB?

We have a server that receives queries. We use the command pattern for this, e.g. q := NewQuery(database) q.Execute(request1) q.Execute(request2) The queries read a "model" from the ...
Maria Ines Parnisari's user avatar
2 votes
1 answer
102 views

Decorate class which inherits from concrete class(es)

In my project I have several "basic" interfaces whose behavior is fixed, i.e. the default implementation will always be good for every puropse. So I defined them as concrete classes with ...
Nicola Mori's user avatar
0 votes
1 answer
60 views

Load Testing for Large-Scale Architecture Involving Cloud Servers and Switches

We currently have an architectural setup as described below. Our plan is to conduct a load test, but we face a challenge due to the high cost of real switches. We have two options: either build the ...
Yiffany's user avatar
  • 101
0 votes
0 answers
80 views

Designing message handler

I am writing an application that receives different kinds of messages from an external device. The messages are of different types and they are received from the device in the form of a string. For ...
Codisattva's user avatar
0 votes
1 answer
121 views

How best to share common steps between services while allowing them to provide their own behaviour

I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult: public IResult FooService(Foo foo) { ... } public ...
hyperfiction's user avatar
1 vote
1 answer
150 views

Design patterns for long chains of computations in python (functions vs classes?)

A recurring pattern which I see in my code is chaining together a lot of functions. This is the result of a large number of processing steps needed for a given task. This could be e.g. a data ...
Jan's user avatar
  • 201
0 votes
0 answers
101 views

better structure of a software project to prevent circular dependencies

I am contacting you today regarding a recent problem with circular dependencies. It's about a Spring boot application that accepts data via a Rest API and then forwards it to an internal Spring ...
Phoenix's user avatar
  • 29
1 vote
2 answers
129 views

Serialization pattern and code duplication

I noticed how our codebase contains multiple versions of the same method, which unmarshalls the inbound byte-stream into java objects and that the only difference between the current and previous ...
Banana's user avatar
  • 121
1 vote
1 answer
130 views

Multiple-operations method pattern

I don't know the name of this pattern but what is the purpose of such methods: AddOrUpdate GetOrAdd instead of single-operation ones?
dstr's user avatar
  • 239
0 votes
1 answer
45 views

What are standard ways to pass the event signal over fixed level only connection?

I need to pass exactly event (not a lasting state) over communication connection that can provide boolean or integer value, possible to set, clear and observe by both sides. It is OPC UA framework but ...
h22's user avatar
  • 917
1 vote
3 answers
234 views

Refactoring a "filter" design

I need to refactor a class that became too messy. The class has a method that reads some raw data from one of our repositories, and another that "filters" it: The data is in the form of ...
RedYoel's user avatar
  • 123
0 votes
3 answers
359 views

Can 1.0.1 be launched right after 1.1.0?

I know that it is common for software to have parallel development in major versions, such as v1 (1.x.x), which can be completely different from v2. Regarding Semver (Semantic Version), can I upgrade ...
lvf23's user avatar
  • 47
0 votes
1 answer
128 views

Is it okay to combine bff and rest api?

I'm building an application related to donation on streams. And I have such models as "alert" and "alert-template". "alert" is a set of different parameters to understand ...
eugenedrvnk's user avatar
0 votes
0 answers
50 views

Spring data exchange between components?

Please advise me what pattern to use in following case: I have a Java/Spring Boot application. There is a component with @KafkaListener method which receives Kafka Messages on CRUD of various subject ...
ALZ's user avatar
  • 107
0 votes
3 answers
246 views

How to reconcile the fact that dependency Injection break encapsulation? (Especially when others are allowed to wire up your dependencies for you)

I was reading Martin Fowlers take on Dependency Injection, and in general have been trying to discuss it a bit online to help get rid of my own misconceptions and to understand this principle better. ...
Scotty Jamison's user avatar
2 votes
1 answer
154 views

Did the term "decorator" originate with OOP design patterns?

The Decorator pattern allows behaviour to be dynamically added to an existing object, effectively "decorating" it with new behaviour. While the pattern as formalised and named seems to have ...
Iain Galloway's user avatar
1 vote
2 answers
245 views

For more than one parameter, when NOT to introduce parameter object?

I know there are some questions about "Introduce parameter object", eg: Is "Introduce Parameter Object" actually a good pattern?, Should we avoid custom objects as parameters?, ...
wcminipgasker2023's user avatar
1 vote
2 answers
190 views

Please explain the "swapable dependency" arguments for IOC containers

I get that IOC containers can be useful to help break dependencies and allow you to test a class in isolation. I don't wish to focus on that right now, instead, I'm trying to understand some of the ...
Scotty Jamison's user avatar
0 votes
0 answers
46 views

Decide pattern(s) for Background service which has dependency on services and service-provider and ServiceBus in .net

I'm designing class library with background service which has public static class ServiceCollectionExtensions Which have few methods which will be call outside. Now above mentioned extension will ...
C M's user avatar
  • 1
1 vote
1 answer
83 views

Access Token Or Alternative for Microservices For Resource Level Granular Checks

Hi I have following structure : Client App (layer 1) Business logic Services ( Layer 2) Business Logic layer consists of many microservices . Access token can be created and passed from APP layer to ...
TechNjBat's user avatar
2 votes
1 answer
225 views

In poltergeist, whats wrong with "solely to trigger or initialize several other objects"? Isn't it is a good use of encapsulation and reuse?

After reading What differentiates function objects from poltergeists?, according to the definition of poltergeist, I still don't understand why would "poltergeist" be a bad pattern: A ...
wcminipgasker2023's user avatar
0 votes
1 answer
136 views

How could I apply the strategy pattern to a react component? [closed]

For the following component, how would I extract the unit logic to allow for composition? In my actual app I am trying to reduce the amount of logic encoded in the component and I have decided that ...
Tyler Kasper's user avatar
2 votes
9 answers
3k views

Is it an anti-pattern to use interface for entity?

I read an article about that using an interface for an entity is an anti-pattern for these reasons: Your interface signature is identical to your class. There’s only one implementation of your ...
Mercury's user avatar
  • 53
0 votes
1 answer
99 views

What C# Object Composition strategy would you apply for CoreObjects with a governing 'ObjectType' property

In a C# ASP.Net Core Web Application I have a Domain Model CentralDesignObject made up of many component objects & properties, producing a significant amount of derived/calculated values. This ...
freedomdev's user avatar
1 vote
6 answers
346 views

How encapsulating what varies can help us?

I have a question about encapsulation and I read these two topic (this & this) but I got more confused. I've been reading Head First Object-Oriented Analysis and Design book and I'm trying to ...
Mehdi's user avatar
  • 21
0 votes
2 answers
145 views

Is this a bad pattern for reporting/audit?

We have a large code base with lots of workflow data (camunda) that does this: Create a reporting event in the codebase Give it a code + payload Put the item on a message queue Consume queue ...
mabeloo52's user avatar
0 votes
0 answers
54 views

Java - How to build a library to record runtime data?

I'm working on building a library in Java which could provide the ability to record runtime data. For instance consider the below code: public interface ItemElement { public int accept(...
user762421's user avatar
0 votes
3 answers
162 views

Event-driven design with delayed consequences

EDIT: more direct situation I need to design a program that will create particular objects and run computationally intensive procedures using its fields in order to update other fields. When a ...
Raphaël's user avatar
  • 119
1 vote
1 answer
132 views

Implementing MVC in C++ with minimal boilerplate despite lack of reflection

Powerful reflection capabilities make implementing nice architectural design patterns such as MVC and Dependency Injection very simple in languages like Java and Kotlin. In particular, reflective tags ...
The_Sympathizer's user avatar
0 votes
2 answers
112 views

Best way of creating different instance types(facotry method) with business logic?

Say I am trying instantiate an instance of a Table. Table here denotes a restaurant table used for eating. Say I have 3 different table types enum TableTypes { SMALL, MED, LARGE } I have ...
curiousengineer's user avatar
0 votes
1 answer
116 views

What is the name of the approach (practice) when several unrelated entities are returned at once in the response to a request [closed]

For example, for a mobile frontend, you need to get all the data for rendering at once. The interface is divided into blocks, in which there can be both blocks with a catalog (categories) and other ...
fogel's user avatar
  • 21
3 votes
0 answers
355 views

Is MVVM appropriate for a .NET MAUI Blazor hybrid app?

I am preparing to create my first .NET MAUI Blazor hybrid app. It is a relatively new technology so there aren't a ton of resources to look at, but of the ones I have found, they are all structured ...
Sudsy1002's user avatar
  • 139
2 votes
1 answer
245 views

Domain models: Can they be an abstract class

When talking about having a rich domain model successfully, in real applications, it needs to, somehow, access some abstraction of complex functionality (instead of being a row state calculator the ...
Vitor Figueredo Marques's user avatar
6 votes
7 answers
7k views

How to avoid repeating "a==b" when comparing "condition a" and then "condition b" and then...?

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 ...
wcminipgasker2023's user avatar
0 votes
1 answer
89 views

Design of system pushing data to multiple systems

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 (...
wetfield's user avatar
0 votes
1 answer
287 views

Some approach or Design Pattern to implement same method different parameters of Interface class

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 ...
Himanshuman's user avatar
0 votes
3 answers
325 views

Use of Visitor pattern rather than enums

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 (...
Postie's user avatar
  • 11
1 vote
2 answers
276 views

design pattern to avoid deadlock with mutex in golang

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 ...
cylon86's user avatar
  • 111
2 votes
1 answer
81 views

Converting the classes with multiple dimension to Bridge design pattern

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 ...
Himanshuman's user avatar
4 votes
1 answer
281 views

Dealing with global variables required by badly-written library

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 ...
Infinite_Maelstrom's user avatar
0 votes
0 answers
29 views

Choosing a Pattern for Handling Different View Models in a Service Method

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 ...
Carel's user avatar
  • 113
-2 votes
3 answers
124 views

What are the pros and cons of different combinations of objects and arrays for data storing?

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', ...
Ooker's user avatar
  • 182
0 votes
0 answers
108 views

Is having many thin factories an antipattern?

I need to perform the following task: for a user [email protected], store a blob of data into their dedicated data store. DataStoreService is what actually stores the blob of data in the user's store, ...
async's user avatar
  • 854
0 votes
3 answers
295 views

Why is Dependency Injection called "alternative of global state"?I think global state still exists

According to Why is Global State so Evil?, I believe we should avoid global state, so suppose I have an App that count user clicks in all pages like it: public class GlobalState{ public int ...
wcminipgasker2023's user avatar
3 votes
4 answers
470 views

When should tuples be used as an argument instead of an array?

I hope this isn't too off-topic/opinion-based, I'm new here. I want to pass three elements of the same type into a function. The three elements are unique cards of a deck of cards, so they're not ...
David's user avatar
  • 49

1
2 3 4 5
89