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
1answer
104 views

Is the Target interface really necessary in adapter design pattern?

I saw a code example online that uses adapter pattern as: if you look at the HR system, the employee information in the form of string array and the ProcessSalary method of the Third Party Billing ...
-2
votes
2answers
241 views

Which design pattern to use for a calculation pipeline with lots of varying rules

I'm currently trying to solve a problem with some legacy code that makes some calculations in order to find out the final value of a monetary benefit. The legacy code uses an imperative approach with ...
0
votes
1answer
688 views

Sharing form validation rules between backend and frontend (Having single source of truth)

I'm currently working on a web app using ASP.NET Core (C#) on the backend and Next.js (TypeScript) on the frontend. I have a lot of forms that need to be validated and I don't want to write validation ...
-2
votes
6answers
194 views

C#, design classes to be scalable

I'm creating an inventory management system, in which the program needs to handle a lot of different equipment, with the possibility for the product owner to increase the selection, without having to ...
0
votes
0answers
26 views

Maintain different versions of the same entity for different locations. Find a standard approach for this

I'm designing an enterprise application (SQL + REST API + Web UI) and I'm trying to find some standard approach for the following problem: Definition: I have a company with multiple locations. I also ...
0
votes
1answer
156 views

How to model derived types (polymorphism?) in DDD

I have Orders which are raised against Contracts, which can be set up as either a fixed price contract or as per price per contracts. During Contract setup, allowed Products are assinged as ...
-1
votes
1answer
75 views

Design for Maintaining changes over time which supports arbitrary updates in different time points

I have a collection of documents, which hold a subject id, a timestamp and a value. For example: { sid: 1, t: 3, v: "A" } { sid: 1, t: 5, v: "B" } Which means subject#1 is ...
0
votes
1answer
180 views

What would the database schema look like for a Entity Component System architecture of web app?

I found previous SE questions like this. I'm familiar with the typical RDBMS backed MVC web app framework. To illustrate what I am thinking of, let's use the examples of Bunny and Carrot from this [...
6
votes
1answer
164 views

Service Design Pattern

I'm working with services and I found out there are at least 3 ways to use them inside controllers... Statically: Like helper, Text::uppercase('foo') Instancing it: $text = new Text(); $text->...
1
vote
1answer
176 views

What design pattern to implement notifications for a .NET application?

I have an ASP .NET web application dashboard that is used to send notifications to several .NET desktop clients. The current implementation is that the web app writes the new notification to a ...
1
vote
1answer
90 views

Loose coupling vs transparency in visitor pattern that visits composite

I have a composite object (I will call it A) that has fixed number of sons (I will call them A1 and A2) All of them have an Accept(Visitor) method. I have a GUI, A is the main window that consists of ...
-1
votes
1answer
79 views

Implementation strategies for dynamically scheduled tasks

This question was completely reedited to be fully in line with the SE guidelines and builds on top of already given comments. I'll try to introduce some vocabulary to better describe the generic terms ...
1
vote
0answers
128 views

Scalable architecture design for managing data flow in C++ using an Observer design pattern

What I need I need a suitable and scalable solution to manage data flow between the classes in my C++ program. Why I need it Upon new feature requests, I'm continually adding new classes to the ...
1
vote
4answers
146 views

Architectural problem for class combination (cartesian product) for save format strategy

Hello to everyone and thank you for any suggestion. I have a family of subclasses of Track (Track is abstract). Every concrete Track has a different number and types of fields (attributes) that extend ...
3
votes
2answers
117 views

Checking the user in almost all use cases

I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
0
votes
2answers
57 views

Approach for using multiple implementation of one interface for a single class, optional to use all or most of them

Consider an interface: interface Auth { fun doAuth() } this can be implemented for multiple APIs: class GoogleAuth : Auth { override fun doAuth(){ throw NoGoogleAuthImpl(); } } class ...
0
votes
1answer
143 views

How do I implement a domain entity behaviour that depends on some external infrastructure?

I am in the process of developing some software using CQRS, ES and DDD. A part of the system is writing services for controlling devices and collecting data from them. Consider a "Start" ...
-1
votes
2answers
157 views

Robins magic Chess game: Where to put/split the behaviour to full fill Law of Demeter [closed]

So now i have a really concrete example; its highly related to that question here: Tell one, but ask the others? the important statements there are: In the comment section https://softwareengineering....
-1
votes
1answer
94 views

Different composition techniques from the perspective of the client

There exists different composition arts/techniques, i will present in the following some of them. The question then is do you know more techniques additional to my presented ones? And then the ...
-1
votes
3answers
223 views

Design pattern for creating and scheduling tests/exams

I have an Exam class that represents an examination/test: public class Exam { public int Id { get; set; } [Required] [StringLength(maximumLength: 30, MinimumLength = 1] public string ...
0
votes
2answers
95 views

How to determine whether (and how) my design should use inheritance, composition, decoration and/or strategy

I want to create a little todo app, with a "pedagogic focus" on clean software design. I spent some time reading about design patterns lately and I am trying to wrap my mind about which of ...
-4
votes
1answer
199 views

Design a login system

I have a task of designing login system with the requirement below: If the user login over three times, lock account for the first 5 minutes. The next failed 3 times login-in will lock the user ...
0
votes
0answers
41 views

Internal behavior VS external behavior with the count of method-parameter

Inspired by my own question + a fragment of Robert Bräutigams answer there: Tell one, but ask the others? i came up with this question here: let's take us the write method of a chatroom or any other ...
0
votes
2answers
142 views

Is there a common Python pattern for the scenario "run code, save the output and load it on a rerun"?

I've been using different ad-hoc variations on this, especially in numpy / pandas / data science-y applications. For example let's say I've done some intensive processing that outputs a numpy array ...
-2
votes
3answers
198 views

Feasibility of a service oriented concept for a device architecture

Assume a device using Raspberry Pi to control some hardware. This diagram tries to clarify the components: SOA concept feasibility is being explored right now. The motivations are: Components in ...
-1
votes
1answer
504 views

Design Pattern for accessing data over RestAPI calls

I am looking out for a general design strategy or pattern designing various components in my client application. Here are high level details: The data is accessed my making a RestAPI call. The data ...
0
votes
1answer
68 views

Memento Pattern:Philosophy of createMemento() method in Originator class

I've question about the philosophy of createMemento() in Originator class in Memento Pattern. My teacher said: now that Originator class no longer stores Memento objects internally, we should give it ...
0
votes
1answer
28 views

Interfacing with records on remote DB from localhost Application Logic

There are times when I have to fix/update records on a Production and/or Staging environment for a Web App. These are remote DBs. Rather than push application code to fix the data, I've been "...
-1
votes
2answers
154 views

PHP Design Pattern, separation of concerns: should the Controller make a new HTTP request to the API?

I'm having a huge doubt on how to connect the front-end of my application to its back-end. So my application has a single entry point where all requests go. The request is dispatched to a controller, ...
-3
votes
1answer
70 views

Pattern for mass action with pre-checks?

Given a collection of objects and an action id (there is a corresponding "action controller" class, which can be found with the id), what is the best way to organize mass action on the ...
1
vote
4answers
206 views

Software-design for algorithm engineering

I'm currently working on an program that solves a graph optimization problem. I know the "standard" software-design principles like information hiding, modularization, etc. What I'm ...
0
votes
1answer
101 views

How to use an API key without knowing it?

let's say I would like to create a service like eToro that allows people to trade stocks but with their own brokers. If I do it just for me, it's pretty straightforward: create logic that replicates ...
0
votes
1answer
70 views

implement a dynamic frontend UI based on roles

We want to build a new frontend for our existing app with elements shown or hidden based on a users role. Are there any common patterns for this? I see two ways of doing this. The backend sends the ...
0
votes
3answers
415 views

Tell one, but ask the others?

Consider we have three classes which want to collaborate, then, where is the behaviour? I guess it can only be in one of the three classes or in a fourth one acting than as a procuedural connector-...
0
votes
0answers
47 views

Multiple endpoints but share the business layer

I am looking at a code base that has multiple APIs and traditional server rendered website. The business logic is duplicated between each of the APIs. I would like to clean this up and share the ...
-2
votes
2answers
182 views

Where to place exception handling while using Decorator design pattern

How to design a service layer structure that will be resistant to exceptions. Let's say I have a simple OrderService service, this service performs basic operations - saving an order. public interface ...
4
votes
1answer
317 views

Dependency Injection: What are advantages of using a framework? [duplicate]

Introduction and Question I understand what the advantages of dependency injection, e.g. constructor injection or setter injection and that it is one way of doing inversion of control. I also ...
-2
votes
1answer
94 views

Scaffold design pattern [duplicate]

I'm looking for something that might be described as a "Scaffold design pattern". I'm in the process of resurrecting an old piece of working but very buggy code that implements a Finite ...
0
votes
2answers
48 views

Handling a column in a database which can change on external conditions

Let's suppose we have a table of products, similar to this one: ProductId ProductFriendlyName ProductPrice 84 Coke can 2 When a specific condition applies (the actual condition isn't really ...
1
vote
2answers
363 views

No trivial god-class refactoring

Consider you have the following code: class UserContainer { List<User> user; //some methods to get specific users, for example users, which are higher than 1,70meters } The User have a ...
0
votes
0answers
38 views

Am I doing Unit Of Work or Context Object pattern against my API, or none of em?

I have created a "simple" C# client library for an HTTP based API (So, think kind of REST.. but yet not.. but that aint important for this discussion anyways, but might be important for some ...
1
vote
0answers
35 views

Managing the output rate for a queue triggered service

I have a service which is triggered by messages from three queues (which are populated by different topics), and writes the processed results to another system (say DB service) synchronously. The ...
0
votes
2answers
171 views

Good design for a class with multiple methods to test but one public method

I've been trying to refactor some existing code which is in essence a giant nested procedural call inside what should otherwise be an object oriented architecture. The entry point to the relevant code ...
3
votes
2answers
119 views

Best approach for inter-process task queues

I have an application made up of multiple processes/workers/services which need to send messages to each other that represent units of "enqueued tasks" to be done. I am trying to find the ...
0
votes
1answer
60 views

Pipeline's outputted data mirroring pipeline's architecture

I'm building a pipeline that scrapes data on entities, to keep things generic, let's call them Widgets. Data on Widgets is currently unorganized and spread across various sources, including source ...
0
votes
2answers
108 views

Is my analogy of an Abstract Factory valid?

After working through several tutorials and reading various responses on this site, I believe the Abstract Factory pattern would work well for a current project. I am seeking the opinions of those ...
0
votes
1answer
109 views

What design pattern (if so) did I apply? How can I further improve it?

Suppose I have a program.c that needs element_123 to do some operations, and element_123 can be accessed by including agent.h /*program.c*/ #include "agent.h" uint32_t element_123 = 0; ...
1
vote
1answer
82 views

Does it make sense to have a facade centralizing events too?

From my understanding a facade is a class with the sole purpose of simplifying the use of a specific system/module behavior (its methods). It should not contain any relevant logic of the underlying ...
-1
votes
2answers
106 views

How to deal with classes with same purpose from different libraries?

I have a question regarding software design/architecture. Are there any best practices or design patterns regarding the usage of classes with the same purpose from different libraries? Let's imagine ...
1
vote
2answers
75 views

c# template method pattern design question

I'm currently in a situation where I have multiple derived class types(just one is shown in the example below) that need to apply some logic before and/or after calling a method implemented in a ...

1 2 3
4
5
85