Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
1 vote
2 answers
119 views

What value does the mediator pattern add beyond dependency injection?

Does the mediator pattern add any value beyond dependency injection? I am encountering the mediator pattern for the first time in context of this sample application, which is meant to demonstrate how ...
jpaugh's user avatar
  • 219
1 vote
1 answer
104 views

Do you re-include system headers in the implementation files?

Here's a scenario: suppose you have #include <unordered_map> in the header and you don't declare it anywhere in the implementation file but you use it, maybe mp[whatever] = some; should you re-...
user129393192's user avatar
4 votes
4 answers
599 views

How to do "Separation of concerns"

I understood(edit: I assume) the importance of seperation of concerns and benifits in an application, But struggling to identify what are considered to be a concern (developer, feature, consumer or ...
Karthi Fair Hawn's user avatar
0 votes
1 answer
73 views

Referencing objects created during seeding by ID

I'm building a software that allows users to extract analytics from a data source. A subset of data periodically is extracted from the data source and stored in a separate database for ease of access (...
Marceli Wac's user avatar
0 votes
2 answers
104 views

What is a good architecture / design pattern for giving multiple shared attributes in different combinations?

I have a need for many different objects to have various combinations of attributes. For a demonstrative example, a flaming dog would have a dog attribute, a flame attribute, and a tail attribute, ...
Fred Etingen's user avatar
0 votes
1 answer
122 views

Is it good practice for object APIs to be required to be called in sequence to gather information?

I had this discussion with someone and it ended ambiguously. Suppose you have a class that needs to Parse a file to gather some information. It can expose this information to you after the fact. ...
user129393192's user avatar
1 vote
2 answers
94 views

Dynamic web application hitting database on front page load to fetch profile image

Folks, I am in middle of writing a web application (Python/Flask) where home page has user profile image in the navbar which is coming from a database (blob), I am wondering if this is a good practice....
afsar's user avatar
  • 19
1 vote
1 answer
128 views

How to implement DMG (Game boy) cpu's register using OOP patterns/principles to max code reusability?

I-m looking to learn better use of OOP principles/patterns so I decided to start implementing at least the basics of a GB emulator (technical part is widely covered on diff sites). So I started with ...
Allende's user avatar
  • 125
-1 votes
1 answer
104 views

Would it be a good design to have multiple repositories for one entity?

I am working on a project. I have designed the codebase all the way from the scratch. Basic thing is the project is divided in individual modules. The modules represent one complete part of a business ...
Muhammad Waqar's user avatar
1 vote
2 answers
114 views

How do I reduce number of FieldValidator derivations?

I am trying to write RSQL Parser which checks if the RSQL is logically correct. while the RSQL Java library checks whether the RSQL expression is grammatically correct, it doesn't check if the ...
Govinda Sakhare's user avatar
0 votes
2 answers
189 views

How to deal with boolean or enum variables used to decide code flow?

I am working on algorithm implemented in C++ that maintains several enum types. Say 3 to 4 enum types each with at least 4 different values. Plus the code maintains several boolean variables. The code ...
Mahesha999's user avatar
5 votes
6 answers
2k views

Is it a good idea to return a Builder from a Factory?

I would want to have a builder for creating a complex object, for example Employee. I would want to be able to create my objects in two ways: Case 1. Get Employee with default values Case 2. Get ...
CuriousGuy's user avatar
-3 votes
1 answer
84 views

Testablilty of setup with builder pattern for configuration

We have built a library which can handle RESTful requests based on configured endpoints. A fluent builder is being used to create endpoint definitions (configurations). These definitions are bound to ...
Wilko van der Veen's user avatar
0 votes
3 answers
181 views

Are there any benefits to delegation over subclassing/inheritance in the case of a singleton?

Example: The MacOS API known as Cocoa uses Delegation to specify various behaviors within the app. A Delegate is a separate object that implements a set of methods that are called by an original ...
CPlus's user avatar
  • 1,187
2 votes
2 answers
217 views

Combining Command and Visitor design patterns

Designing the architecture of a personal project, I've come up with the idea of using the combination of these two patterns to solve an architectural issue. In an MVC context, I need to implement ...
Gareg's user avatar
  • 23
-3 votes
2 answers
103 views

Company and person or just contact table [closed]

Given the two models company and person I'm noticing duplicate fields i.e. zipcode, emailaddress for each. Yet, a short research reveals a reasonable popularity for separating those two entities into ...
jjk's user avatar
  • 545
-1 votes
2 answers
108 views

Algorithm for realtime database listener replacement?

I have a time-series database where I put all my data in it in timely-ordered fashion. Unfortunately, the database doesn't have any realtime listener capability built into it, and I need to make an ...
Riki Syahputra's user avatar
-1 votes
1 answer
47 views

service mesh and domain driven design

So we have a cluster with namespaces representing different domains. Services in one namespace cannot directly talk to services in another namespaces unless routed through a load balancer. ( goes ...
TechNjBat's user avatar
-1 votes
3 answers
135 views

Possible Solutions for avoiding applications sharing database

Background: I work on a small group (5-10) of lightly used .Net web applications. The applications typically have dedicated databases, but there are instances of an application accessing another ...
jessiebot's user avatar
1 vote
2 answers
167 views

Does my business case need TPL dataflow?

We are trying to rewrite a session management system as our legacy system can't scale up anymore and is quite buggy. I'll briefly explain our system, we have huge number of machines on which end users ...
user1890098's user avatar
0 votes
0 answers
47 views

isolating user run scripts on docker without performance impact

Scenario: We have a application (web based), in a small part of this application a users is able to create a small python script to mutate (in memory) data. Currently all of these scripts (if it is ...
Vincent's user avatar
  • 375
0 votes
2 answers
184 views

Source Control Design for Proprietary Logic which includes Obfuscation

Problem: There are proprietary algorithms that developers who are actively working on a project will need to call but they should not see the underlying logic. They need to be stored in an area of ...
Rudazzle's user avatar
0 votes
4 answers
180 views

How to eliminate repetition in three subclasses: each defines an identical method that does almost the same thing, but with a different return type

TLDR: I have three subclasses, each inherits from the same parent class, each defines an identical method that does almost the same thing, except that each of these methods has a different return type....
thatUserHOverThere's user avatar
1 vote
2 answers
139 views

Does the Mediator Pattern Solve the Same Problems as a Queue?

I am very unfamiliar with the Mediator Pattern in practice, but it seems that the core is decoupling events from handlers ("Colleagues"). The benefit being "lose coupling" in the ...
VSO's user avatar
  • 179
-3 votes
1 answer
146 views

How should I architect a cricket scoring app?

Cricket scoring is complex and I want to build an app in part to practice good design principles/patterns and develop a clean solution. A few high level classes I have in mind are: Match | Innings | ...
zadane's user avatar
  • 387
1 vote
1 answer
300 views

When shall one ignore the absurdity of some code diagrams?

I wrote a relatively small user interface for Unity, whose job is to ease working with parts in a scene, i.e. show/hide/toggle objects to reduce clutter. Long story short, I refactored it to use their ...
aybe's user avatar
  • 765
0 votes
0 answers
43 views

Setting Dependency Design

Hello I'm currently designing an GUI application who's main job is to update and display settings and some other data. For context, I'm using QT framework. I'm starting to refactor the settings ...
mcmatt90's user avatar
-2 votes
3 answers
173 views

Class inheritance design with protected methods and run time base handlers

Using C#, I got a class called BaseConfigurations which handles CRUD operations. This class also contains a protected method which is used inside the CRUD handling methods: public class ...
CodeMonkey's user avatar
2 votes
4 answers
738 views

Why blaming "global state", instead of my user requirements, makes program state unpredictable?

According to Why is Global State so Evil?, I know I should not allow the existence of global state, one of the reasons is so called "it makes program state unpredictable". However, I'm not ...
wcminipgasker2023's user avatar
2 votes
2 answers
511 views

Is this architecture overkill? What is a good way to architect this software?

I have an algorithm I am trying to implement that has steps 1 to 5. There are several different ways I could implement each step. Each calculation step is essentially just an astronomy calculation, ...
Hunter's user avatar
  • 187
0 votes
1 answer
118 views

Should I "introduce parameter object" for the case that the parameter is originally already a whole object?

According to Should we avoid custom objects as parameters?, for example, if I have an object to show: public class Student{ public int _id; public String name; public int age; public ...
wcminipgasker2023's user avatar
0 votes
1 answer
143 views

How to model in OOP interactions with entities in other systems?

Assume we are designing a typical bank account management system. Customers can have one or more accounts. Customers can deposit cash, withdraw cash or transfer money to another account (and, of ...
A. Darwin's user avatar
  • 109
0 votes
1 answer
152 views

How to correctly extend runtime exception?

We have a GraphQL server which sends data to the front end client. We have other tenants who will use our sever and host their code. I want to create a system where they all can create any custom ...
user415612's user avatar
1 vote
1 answer
114 views

Design User Permissions

I'm building a ToDo list while practicing in different patterns and adding more complexity to the project. The problem which I'm currently facing is to how to apply (and later use, validate and ...
Roman's user avatar
  • 11
2 votes
5 answers
219 views

Does the Visitor Pattern necessitate traversing a structure of instances?

I have a class hierarchy of elements (more static) with different operations on them in another class hierarchy (more flexible). During execution there is exactly one element given, and based on it's ...
Philipp Murry's user avatar
2 votes
3 answers
207 views

Displaying a list of similar but different objects without resorting to type checking

I'm creating the UI for a "Point of Sale" type page. You can add orders, grouped orders, and custom items to your transaction, and it should display these in a list so you can see what you ...
Conman_123's user avatar
3 votes
4 answers
1k views

Representing vectors as arrays of points vs. as data structures

I'm writing a program in Java where I need to represent the position, scale, and other 3-dimensional properties of objects in a world using vectors. I can use either of these two approaches: ...
AcinonX's user avatar
  • 613
0 votes
4 answers
200 views

Best practice for using read-write lock

Given a system where users can access different services through the API for conducting business transactions, I am currently working on integrating a read-write lock into the system. One approach I ...
YiLuo's user avatar
  • 9
24 votes
11 answers
8k views

Is it logical to not use inheritance because the function is critical?

Our codebase has a typical base-class with a ton of sub-classes. The base-class already has many default functions for the sub-classes. However, one particular function has the same verbatim ...
Zack Light's user avatar
0 votes
4 answers
138 views

What is the advantage/disadvantage of returning a UnSubscribe class to Observer as opposed to just calling a UnSubscribe method of Observable?

There are two ways to provide a way unsubscribe in Observer Design Pattern. 1. Provide a simple void UnSubscribe method: public void UnSubscribe(IObserver observer){ // remove observer from List of ...
SamuraiJack's user avatar
1 vote
5 answers
316 views

DTO vs POJO (Entity) on POST request

If I have for example a User POJO like the following @AllArgsConstructor public class User { @Id private final String id; private String username; private String password; private Date createdDate;...
iqueqiorio's user avatar
0 votes
2 answers
131 views

Push and Pull Communication in object oriented: why Push style is not flexible?

I'm trying to learn Observer Design Pattern and I started to watch the series which belongs to codewithmosh called "The Ultimate Design Pattern Series". in the lesson which was about ...
Mehdi's user avatar
  • 29
-2 votes
2 answers
172 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 ...
Logan S's user avatar
  • 11
0 votes
0 answers
94 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....
Paul Marcelin Bejan's user avatar
1 vote
1 answer
101 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 ...
dig_123's user avatar
  • 137
0 votes
1 answer
141 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
147 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
  • 203
2 votes
2 answers
234 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
  • 33
3 votes
1 answer
103 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
167 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
2 3 4 5
90