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
2 votes
2 answers
79 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 ...
0 votes
0 answers
37 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 ...
331 votes
16 answers
173k views

Do I need to use an interface when only one class will ever implement it?

Isn't the whole point of an interface that multiple classes adhere to a set of rules and implementations?
2 votes
2 answers
462 views

Exposing methods for polymorphic children from the aggregate root

Consider the following fictitious toy example: There is an aggregate root DayChecklist that holds a list of Tasks planned for the day: class DayChecklist { String id; DateTime today; ... ...
-1 votes
0 answers
54 views

Design for adding an additional version of a service to live side by side with the first one

This is a follow up question to this question: Class inheritance design with protected methods and run time base handlers I want take a step back from the previous question - that one was an issue ...
-2 votes
3 answers
151 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 ...
0 votes
2 answers
165 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 ...
0 votes
4 answers
164 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....
1 vote
2 answers
112 views

Access Token Or Alternative for Microservices For Resource Level Granular Checks

Hi I have following structure : Client App (layer 1) Business logic Services ( Layer 2) Business Logic layer consists of many microservices . Access token can be created and passed from APP layer to ...
1 vote
2 answers
108 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 ...
-3 votes
1 answer
134 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 | ...
-1 votes
1 answer
435 views

How should the structure of external API calls in an electron application be designed?

In this scenario, my renderer process' goal would be to make an HTTP request to an external web server and receive responses. My question is: which options below would be more secure, give a future ...
2 votes
4 answers
705 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 ...
5 votes
4 answers
783 views

Designing a flexible search API response

Quick Summary I'm building a search micro-service that will allow searching across different types of resources in a particular system (e.g. blog posts, users etc.). The API that will be exposed will ...
1 vote
1 answer
272 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 ...
427 votes
18 answers
176k views

Why is Global State so Evil?

Before we start this, let me say I'm well aware of the concepts of Abstraction and Dependency Injection. I don't need my eyes opened here. Well, most of us say, (too) many times without really ...
0 votes
0 answers
42 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 ...
10 votes
5 answers
5k views

Can we completely replace inheritance using strategy pattern and dependency injection?

For example: var duckBehaviors = new Duckbehavior(); duckBehaviors.quackBehavior = new Quack(); duckBehaviors.flyBehavior = new FlyWithWings(); Duck mallardDuck = new Duck(DuckTypes.MallardDuck, ...
2 votes
2 answers
467 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, ...
10 votes
3 answers
23k views

What's the difference between Observer pattern and listeners?

I have used some kind of "listeners" where I have an interface implemented by classes that need to be notified of some event (e.g.: CurrencyListener, with a method currencyUpdated(Currency ...
0 votes
1 answer
132 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 ...
0 votes
1 answer
108 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 ...
0 votes
1 answer
216 views

Where to create repository instances?

I've several repositories. To make them testable, I add the ORM session in the constructor. class Repository: def __init__(session): self.session = session def save(object): self.session()...
0 votes
1 answer
138 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 ...
3 votes
2 answers
6k views

What are the best practices to use NHibernate sessions in asp.net (mvc/web api)?

I have the following setup in my project: public class WebApiApplication : System.Web.HttpApplication { public static ISessionFactory SessionFactory { get; private set; } public ...
3 votes
2 answers
260 views

Visitor pattern applicable ? - Applying rules to a list of registrations

I have a list of Registration's, on which I need to apply a set of rules to each individually. Rules can be a single Rule, or a sequence of rules, representable by a tree. One rule is a ...
0 votes
1 answer
315 views

Observer pattern using static events

I'm working on a game prototype: I have a Cell class which, given a mouse click on its collider, can raise an event that should be listened in two different modules: Camera and UI. The Observer ...
2 votes
5 answers
209 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 ...
30 votes
6 answers
9k views

Visitor Pattern: what's the point of the `accept` method?

I'm trying to fully understand the visitor pattern. What I've learnt so far (correct me if I'm wrong) is: It's about adding operations to classes, without modifying the source code of those classes. ...
1 vote
1 answer
100 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 ...
6 votes
1 answer
418 views

How to set up a sql database to cater for user records, group records and default records?

Outline I have an application that loads data from a database. I'm not talking about client data here though, I'm talking about application configuration. The database will therefore come with some ...
16 votes
4 answers
12k views

“Depend on abstractions, not on concretions” what is the exact meaning of this term

I was reading SOLID principles on a website, in which for D - Dependency Inversion Principle it says: “Depend on abstractions, not on concretions” In other words. we should design our software in ...
1 vote
2 answers
430 views

Chain of responsibility or simple dependency injection for Querying API

I am working on refactoring a project code that is wired up in a tangled way. It was started with decent dependency injection and over time with all custom requirements it looks it got tangled up. ...
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: ...
2 votes
3 answers
205 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 ...
169 votes
18 answers
293k views

Is it better to return NULL or empty values from functions/methods where the return value is not present?

I am looking for a recommendation here. I am struggling with whether it is better to return NULL or an empty value from a method when the return value is not present or cannot be determined. Take ...
5 votes
2 answers
3k views

Design patterns and multiple programming languages

I am referring here to the design patterns found in the GOF book. First, how I see it, there are a few peculiarities to design pattern and knowing multiple languages, for example in Java you really ...
1 vote
1 answer
221 views

State Pattern when the Behavior in Object of Type A is Dependent on the State of the Object of Type B

I have used the state pattern for my web application where a user can be in one of three states: activated, required_activation and suspended. I have created 3 states classes as given below (source is ...
0 votes
1 answer
122 views

Design of system pushing data to multiple systems

I have a ASP.NET Core backend (with Azure Service Bus) and a Blazor Server frontend. The purpose of the backend and the frontend is to trigger manual and automatic pushing of single data points (...
10 votes
3 answers
2k views

Balance between aggregate boundaries and domain consistency in DDD

Designing an Aggregate and choosing an Aggregate Root getting tricky for me all the time especially when it comes to ensuring right transactional contexts and consistency constraints so I'm wondering ...
6 votes
6 answers
462 views

Best practice to architect a system in which local users may override global definitions

Our travel industry client, operating across three continents and several countries, wants to standardize the process of choosing travel packages, air routes, hotels, and hundreds of other travel ...
10 votes
4 answers
14k views

Is "Introduce Parameter Object" actually a good pattern?

I have a situation where I want to call a function which requires a number of parameters. This function is not called directly, it is called indirectly and the parameters are delegated several times. ...
3 votes
1 answer
332 views

Data processing pipeline design for processing data

I have a use case for which I need to build a data processing pipeline Customer contact leads data coming from different data sources like csv, data base, api has to be first mapped to a universal ...
0 votes
4 answers
177 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 ...
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 ...
13 votes
5 answers
3k views

What kind of logic can Domain Objects realistically contain?

I have been struggling with this concept in the context of web applications ever since I first read about it. The theory states that the domain objects should encapsulate their behaviour and business ...
2 votes
1 answer
105 views

Converting the classes with multiple dimension to Bridge design pattern

Bridge design pattern is something which is very confusing and GOF does not do justice with beginners in the definition. I was asked in my current organisation to add one more dimension to our class ...
1 vote
5 answers
202 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;...
-2 votes
2 answers
169 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 ...
0 votes
4 answers
129 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 ...

1
2 3 4 5
89