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
-2 votes
1 answer
89 views

Quiz Site Software Architecture Question

I am currently writing an application that is going to be an adaptive quiz-like site for studying. The idea is a user is studying some topic and they are given questions on the site and enter their ...
0 votes
0 answers
91 views

By creating an architecture, it is better to have many classes that handles different scenarios, or a single one that handles all? [duplicate]

During my limited professional experience, I have been involved in microservices projects with a common structure: The Controller takes a request and validates it using the jakarta.validation....
1 vote
1 answer
71 views

How does a Bounded Context from DDD help scaling microservices?

New to the microservices architecture - but what I've picked up so far doing some research while designing a microservices architecture for a home rental system is these: Individual microservice ...
2 votes
2 answers
2k views

Repository pattern - using information from other repositories

I am trying to understand what is the proper approach when the objects generated from a Repository have a reference to objects which are responsible for another Repository. Let's say I have terminals ...
1 vote
1 answer
373 views

MVC-like architecture: Model-Controller communication of results/status

I'm struggling on designing a solid architecture for my project. In particular, I don't know how to handle the communication between the models and the controllers. My goals are: Following the ...
2 votes
2 answers
237 views

Data getter inside Model or ViewModel in MVVM

I'm working on an app I created for myself using the MVVM architecture. On my ViewModel I have a list_items that, when changed, updates the corresponding UI element on the View. The list of items ...
0 votes
1 answer
131 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 ...
72 votes
7 answers
76k views

What is a helper? Is it a design pattern? Is it an algorithm?

Maybe a little tongue-in-cheek, but as I can't find this answer anywhere through Google, so to ensure Software Engineering has the answer: What is a helper? I have seen the name being used ...
1 vote
2 answers
208 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 ...
2 votes
1 answer
98 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 ...
3 votes
3 answers
1k views

Is Enum Polymorphism bad for DAO Methods?

I have been going back and forth in a discussion about polymorphic enums to call different DAO methods depending on enum entry, and I haven't been able to get a common agreement on this subject. Lets ...
3 votes
1 answer
86 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 ...
54 votes
3 answers
17k views

What is the purpose of NaN boxing?

Reading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit ...
1 vote
1 answer
257 views

Could this be considered a valid State GoF Pattern implementation?

For teaching purpose, I would like to create a simple implementation of State Pattern using PHP 7.4. So, I've tried to create a simple "document state machine" starting with Draft, sending to review ...
1 vote
6 answers
347 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 ...
1 vote
1 answer
456 views

Organizing reducers in Redux

I will use the following popular todo list example for demonstration. Let's say I wanted to create a very basic todo list with this structure as the app state: { todos: { todoKey1: { ...
2 votes
2 answers
490 views

Design of a modular application

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions. I have ...
1 vote
2 answers
159 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 ...
0 votes
2 answers
113 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 ...
0 votes
2 answers
110 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 ...
0 votes
1 answer
275 views

Static data reuse

I'm going to describe the situation first and ask questions in the end. I need to validate a scalar value using the Symfony Validator component. The value is an associative array. Now I have defined ...
1 vote
2 answers
194 views

How to design relationships with constraints on subclass type?

I'm developing a full-stack Rest application following a narrative description of a working context. There is a class Job with two subclasses Job_A and Job_B. Job_A produces Report_A while Job_B ...
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 ...
2 votes
1 answer
158 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 ...
1 vote
2 answers
1k views

How to design an API wrapper with bulky operations on domain object? (Need guidance)

I need some guidance in designing an API wrapper for my backend APIs. I have tried to keep it as specific as possible. Context: We have a project which supports certain file operations like edit, ...
3 votes
1 answer
2k views

Unit Testing in VIPER Architecture: Possible?

TL;DR There are no methods in VIPER which are returning any value so how to test them? Reasoning: In VIPER, each layer is communicating with other layer by holding an abstract reference to it (...
0 votes
1 answer
130 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 ...
47 votes
6 answers
57k views

Is "Mapper" a valid design pattern or is it a variation of the "Factory" pattern?

A common pattern I see is what's known as the Mapper pattern (not to be confused with DataMapper which is something else entirely), which takes as an argument some kind of "raw" data source (e.g. an ...
0 votes
1 answer
123 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 ...
5 votes
3 answers
1k views

Handling common code among presenters

I'm facing some issues related to code duplication when following MVP architectural pattern in an Android project that I'm working with. My project structure is separated by packages: data, domain, ...
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 ...
2 votes
1 answer
562 views

Creating an internet gateway for a Bluetooth Low Energy device

I have a device that connects using Bluetooth Low Energy (BLE). I want it to communicate with a server over the internet using a smartphone as a gateway. I have thought of different approaches and I ...
0 votes
0 answers
82 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 ...
2 votes
1 answer
153 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 ...
0 votes
0 answers
102 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 ...
0 votes
4 answers
2k views

Should an MVP/MVC Model contain behaviour?

I have read plenty of questions on here, which appear to confuse the MVP/MVC Model with the Domain Model. In my mind the MVP Model calls the Service, which then calls a rich Domain Model i.e. the MVC/...
1 vote
2 answers
2k views

Java Design for Data enrichment based on logic defined in a database

I have the following requirement. Read data from a messaging Queue and process each message to enrich the message and then finally send the enriched message to a different system. The enrichment ...
2 votes
2 answers
412 views

Exposing methods for polymorphic children from the aggregate root

Consider the following fictitious toy example: There is an aggregate root DayChecklist that holds a list of Tasks planned for the day: class DayChecklist { String id; DateTime today; ... ...
1 vote
2 answers
131 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 ...
28 votes
8 answers
7k views

Coupling: Theory vs Reality

Coupling is defined as the knowledge one object has about another one, which describes how dependent they are. The more dependent, the worse, since changes in one would impact in the second. High ...
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?
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 ...
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 ...
1 vote
3 answers
240 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 ...
0 votes
1 answer
325 views

How should the structure of external API calls in an electron application be designed?

In this scenario, my renderer process' goal would be to make an HTTP request to an external web server and receive responses. My question is: which options below would be more secure, give a future ...
29 votes
6 answers
9k views

Visitor Pattern: what's the point of the `accept` method?

I'm trying to fully understand the visitor pattern. What I've learnt so far (correct me if I'm wrong) is: It's about adding operations to classes, without modifying the source code of those classes. ...
5 votes
3 answers
735 views

Designing a flexible search API response

Quick Summary I'm building a search micro-service that will allow searching across different types of resources in a particular system (e.g. blog posts, users etc.). The API that will be exposed will ...
5 votes
1 answer
2k views

How to handle the Dependencies between Secondary Actor Adapters in the Hexagonal Architecture

I am applying the principles of Hexagonal Architecture (Ports and Adapters) and one aspect is slightly bothering me. In my opinion, the ports and adapters of the secondary actors should completely be ...
0 votes
3 answers
368 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 ...
4 votes
4 answers
675 views

Pattern for endpoint that routes requests?

I am building a service that will push notifications to many other services. It has a couple of different notification types that each consumer may care about, but likely will not care about all of ...

1
2 3 4 5
89