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 ...