Skip to main content

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
141 views

Does ReactJS Compound Pattern violate the DRY principle?

Let's say we have this component: const Card = ({ title, description, price, tag, category }) => { return ( <div> {title && <h5>{title}</h5>} {...
Oktay Yuzcan's user avatar
0 votes
0 answers
52 views

A Design Pattern for a component which both writes to and reads from an ordered event log

I am searching for a good design for a set of components I am writing for a system. I believe it is very likely there is a Design Pattern, or set of Design Patterns, which could be combined to solve ...
user3728501's user avatar
1 vote
1 answer
83 views

How to Handle Additional Parameters in State Transition for State Pattern in C++

I'm implementing a state pattern in C++ with a context and several states. Each state implements its transition. Here's a simplified version of what that design could look like: class Context; class ...
Emile Papillon-Corbeil's user avatar
2 votes
1 answer
122 views

For N and NBuilder, should N be an instance variable of NBuilder, or all parameters of N be instance variables of NBuilder,finally new N() in build()?

As far as I know about builder pattern, for example, an object, Student: public class Student{ private String name; private int age; //setter and getter } to apply builder pattern to ...
wcminipgasker2023's user avatar
2 votes
1 answer
113 views

Why memento is required while originator can do the job?

One thing is disturbing me about the Memento Design Pattern. Why should we use the Memento object to replicate the Originator state to store it for future restoration? Can't we use the Originator ...
Shikhor Roy's user avatar
3 votes
1 answer
156 views

Seeking Clarification on the Abstract Factory Pattern

I am seeking clarification on the exact purpose and definition of the Abstract Factory pattern. According to the GoF (Gang of Four) book, the intent of the pattern is to: Provide an interface for ...
Codisattva's user avatar
3 votes
3 answers
235 views

Handle hierarchical relationships between large number of enums

I am working on a C# project and I have a somewhat large number of labels (~100) that have some sort of relationships between one another. Here is a minimal dummy example that illustrates this: ...
evolved_antenna's user avatar
0 votes
0 answers
41 views

Muti-tenant Webapp Setup Defaults and Configurations

I have a multi tenant webapp. When a new tenant is created there is a bunch of defaults and configurations that need to be created in the DB for the new tenant, so of these inserts are related to each ...
iqueqiorio's user avatar
1 vote
4 answers
242 views

Why are there two abstract interfaces in the observer pattern?

I'm reading about design patterns from both "Head First Design Patterns" and the original "Elements of reusable software etc" and I'm finding some confusion right at the start, in ...
Maldus's user avatar
  • 126
23 votes
5 answers
16k views

Are "factory methods" anti-pattern now?

I consider Joshua Bloch's Effective Java the best book on the language that I read. However, I started to wonder about something One of the things he suggested was to prefer public static factory ...
demavi's user avatar
  • 347
3 votes
2 answers
191 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
  • 239
1 vote
1 answer
122 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
697 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
82 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
120 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
140 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
100 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
137 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
152 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
121 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
223 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
87 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
191 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,189
1 vote
2 answers
274 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
  • 21
-3 votes
2 answers
109 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
116 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
52 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
147 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
180 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
51 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
  • 383
0 votes
2 answers
190 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
  • 111
0 votes
4 answers
184 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
171 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
164 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
  • 397
1 vote
1 answer
306 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
  • 763
0 votes
0 answers
47 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
178 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
754 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
529 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
122 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
145 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
167 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
146 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
226 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
217 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
234 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
160 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
2 3 4 5
90