Questions tagged [design-patterns]
A design pattern is a general reusable solution to a commonly occurring problem in software design.
4,519 questions
1
vote
4
answers
156
views
Is it good practice to return ApiResponse from a Spring service layer?
I'm working on a Spring Boot application with a VoucherService and VoucherController. I currently have the service method return an ApiResponse<T> directly, like this:
@Transactional
public ...
2
votes
2
answers
304
views
How to design extensible data aggregation code to avoid manual updates in multiple places?
I have a data aggregation function that collects statistics from multiple sources. The problem is that whenever I add a new metric, I need to manually update the code in three different places, which ...
2
votes
7
answers
359
views
I'm looking for a design principle referring to using a system for it's intended purpose
Recently a junior team member was asked to use a survey tool to act as a system by which fuel delivery drivers could submit their Bill of Lading to our dispatch team for record collection after ...
0
votes
6
answers
291
views
Design pattern for exposing different parts of interface to different entities
In a certain program I would like to have three objects, say, a, b, and c, with c being a shared private member (sub-object) of a and b. The data between the three objects shall only go this way:
a &...
1
vote
1
answer
152
views
Optimal way to match prioritized list of tasks with available workers
Problem
Match prioritized tasks with suitable workers.
Details
Consider a task with following properties - type and size. Based on task type, tasks are prioritized.
While a worker has following ...
0
votes
1
answer
114
views
Designing a Scalable Caching Layer for User and Tenant Metadata in a Messaging System
I'm developing a microservice-based application that processes a high volume of messages. Each message must be handled according to the user’s personal settings and some tenant-specific (customer) ...
0
votes
0
answers
76
views
When DI goes too deep - what is another architecture/design pattern you should use? [duplicate]
I like using dependency injection but sometimes I find that I have to nest some dependencies so deep that I would almost rather use a global variable (despite this being bad practice). Here is an ...
3
votes
1
answer
194
views
How should User behaviour depending on role be design as OOP
Imagine I got user which might be either author, administrator, reviewer
An author have relation on book that he wrote.
An administrator have relation on banned user (we track which administrator ...
2
votes
3
answers
166
views
Is this an aggregate in DDD? Is it unnecessary to group objects as an aggregate if there are no invariants?
Below is a scenario that needs to be modeled using the Domain-Driven Design (DDD) approach.
A Project can have Notes added to it.
A Note cannot exist without a Project.
A Note needs to be
viewable ...
3
votes
3
answers
492
views
Is it a good idea to wrap node.js package functions in a micro-service architecture?
Our development team works with a micro-service node.js architecture. This means we work with a very large amount of repositories that currently each take care of their own dependencies.
To avoid ...
4
votes
2
answers
713
views
why would one use the "Functional Options" pattern in go?
I just learned about the Functional Options pattern in golang.
what are the benefits of using it over just allowing to pass a config struct and just overriding the default values provided in the ...
1
vote
3
answers
311
views
How to handle authorization in CQRS
In a CQRS architecture, at least as implemented by Vaughn Vernon in IDDD_Samples, the query services lives in the application layer. But then where and how should authorization be handled?
For example,...
3
votes
5
answers
1k
views
What is the design pattern of a program that uses global arrays to store variables?
Specifically, I mean code structured in a way where storage is global. Bare with me, as my terminology is all over the place. If I want to create a variable, I "load" it into a global cache. ...
2
votes
3
answers
317
views
Aggregate with a huge list of value objects
I'm currently reading "Implementing Domain-Driven Design" while going through the code samples, but I'm having trouble modeling aggregates that stores a huge list of value objects. For ...
21
votes
5
answers
4k
views
How manage inventory discrepancies due to measurement errors in warehouse management systems
I'm developing an enterprise-grade warehouse management application for a chemistry laboratory. A critical feature involves mixing multiple stock solutions to create new solutions based on predefined ...
2
votes
3
answers
998
views
Is breaking encapsulation a necessary compromise for serialization?
I've been considering the way to solve this problem for a while, and I'm currently stuck between two options I both feel are suboptimal. Here's an abstract example of what I'm dealing with:
I have a ...
-2
votes
1
answer
215
views
Best Practices for Managing Multiple Entity Types in ASP.NET Core
I'm working on an ASP.NET Core application that requires handling multiple types of a single entity. Each type has its own properties and validation rules, which has led to confusion and complexity in ...
1
vote
2
answers
203
views
Decoupling UIs from Domain logics | Clean architecture
I've been reading articles on Hexagonal, Onion, Clean Architectures, and other Domain-Driven Designs. A common theme they emphasize is decoupling components. From what I gather, this means the UI ...
2
votes
3
answers
275
views
What options are there to handle dependencies that may error?
I have an application, which contains a logger. The logger already exists and is ready to be used, so it can be passed directly to the constructor.
class App {
private readonly logger: Logger;
...
0
votes
2
answers
128
views
Aggregating classes to emulate multiple constructors using factory methods
I'm trying to make a utility Master class for aws client, and have mainly come across 2 types of commands/operations. Ones that require the S3Client, and others that do not. Therefore, I divided the ...
-2
votes
1
answer
234
views
Transaction Management Across Microservices with Rollback Mechanism using Kafka
I am currently developing a microservices architecture consisting of two services, and I'm facing a challenge related to transaction management and error handling.
Microservice A: This service is ...
2
votes
4
answers
446
views
Builder with non-defaultable required args
Suppose a class needs multiple properties of the same type. I don't want a big constructor where the user can mess up the order of args (remember, they are of the same type, no compile-time errors)
...
3
votes
6
answers
608
views
Trying to write a sane alternative to the visitor pattern, please help me review it
EDIT: This post has a single question but a lot of context. The single question is if there are downsides with the approach I'm taking over the common Visitor pattern.
I've been thinking about the way ...
1
vote
1
answer
316
views
What are the common design patterns for updating user data of a desktop/mobile application?
Question:
What are common architecture patterns/strategies of updating user data (think of XML/Json/sqlite/custom binary format) when the format of the data needs to be changed, and when that change ...
2
votes
1
answer
174
views
Should I create another API to “move” content or modify my existing API that already does something similar?
I have a Spring Boot REST API that will copy content from one Amazon S3 bucket to another. The source and destination buckets are specified in the body of a POST request sent to the API. This works ...