Questions tagged [design-patterns]
A design pattern is a general reusable solution to a commonly occurring problem in software design.
4,524 questions
10
votes
5
answers
2k
views
Is it good practice to include utility methods as properties in data models?
My app is an Android app where I pass the below User object to all the screens.
This class contains hour format and timezone properties that determine time formatting preferences:
data class User(
...
0
votes
1
answer
79
views
Web application tied to a single reality: design patterns to generalize it [closed]
A web application was realized for the specific needs of a production plant.
Now the customer wants to extend its use to a second production plant and in the future to others.
Production plants look ...
0
votes
0
answers
51
views
How to abstract data provision in django?
Say myModel's data should be populated from multiple third party providers llm/api data.
I want to avoid repeating the get_response logic in multiple models.
My current thoughts consist of inheriting ...
5
votes
3
answers
242
views
How to organize multiple customized projects around a shared and evolving codebase?
I currently have around twenty GitHub repositories used by one group of developers. Each repository is a Spring Boot Java microservice.
I now want to open these repositories to a second group in order ...
2
votes
4
answers
573
views
Are there any functional approaches, to have variables that feel global (no need to pass them around explicitly), yet are local to an instance?
I'm developing a library in JavaScript (TypeScript, actually) which is split into several modules. It's meant to run both on the web and in non-web environments like Node.js.
The library is meant to ...
1
vote
4
answers
237
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 ...
-3
votes
1
answer
227
views
Is there a name for this anti-pattern? (reference to a class member passed to another class method) [closed]
Is there a name for this anti-pattern?
A reference to a class member is being passed to another class method, rather than having the class method set the class member directly.
public class ...
2
votes
2
answers
319
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 ...
1
vote
1
answer
286
views
OO design - Process that relies on the current state of objects
We have a CAD software extension, where you can draw products like walls, doors, windows, etc., and you can export the drawing as an order, which contains the parts and costs.
As part of this export, ...
2
votes
7
answers
408
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
1
answer
152
views
Best practices for serving encrypted files in Laravel?
I'm building a Laravel-based web application that functions as a personal online photo archive. Each user uploads and manages their own private collection of images. These images are encrypted at rest ...
1
vote
6
answers
345
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 &...
0
votes
1
answer
182
views
Optimal way to avoid iterating through each row in a dictionary of data/arrays?
I have an excel macro that imports daily share price files, and finds the highest price for a share after a given date.
Each of these daily stock price files has ~1000 rows of data. Currently I have ...
1
vote
1
answer
181
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
111
views
Designing a Clean Separation for API Sorting Parameters and Database Columns
I'm working with a data mapper called UserMapper and a User model. Currently, UserMapper has a method called find_many. Now, a client makes requests like /api/users?sort_by=+last_name,-birthdate, so I'...