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
4 answers
150 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 ...
user avatar
  • 27
3 votes
2 answers
120 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 ...
user avatar
0 votes
2 answers
58 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 ...
user avatar
  • 117
0 votes
1 answer
229 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" ...
user avatar
  • 11
-1 votes
2 answers
158 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....
user avatar
-1 votes
1 answer
95 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 ...
user avatar
-1 votes
3 answers
225 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 ...
user avatar
  • 63
0 votes
2 answers
96 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 ...
user avatar
  • 119
-4 votes
1 answer
235 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 ...
user avatar
  • 1
0 votes
2 answers
147 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 ...
user avatar
-2 votes
3 answers
202 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 ...
user avatar
-1 votes
1 answer
890 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 ...
user avatar
0 votes
1 answer
74 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 ...
user avatar
0 votes
1 answer
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 "...
user avatar
-1 votes
2 answers
200 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, ...
user avatar
-3 votes
1 answer
71 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 ...
user avatar
  • 1,693
1 vote
4 answers
209 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 ...
user avatar
0 votes
1 answer
107 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 ...
user avatar
  • 9
0 votes
1 answer
90 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 ...
user avatar
  • 1,764
0 votes
3 answers
421 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-...
user avatar
-2 votes
2 answers
261 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 ...
user avatar
  • 289
4 votes
1 answer
411 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 ...
user avatar
  • 297
-2 votes
1 answer
109 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 ...
user avatar
0 votes
2 answers
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 ...
user avatar
  • 59
1 vote
2 answers
406 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 ...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 19
0 votes
2 answers
232 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 ...
user avatar
  • 23
3 votes
2 answers
126 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 ...
user avatar
  • 139
0 votes
1 answer
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 ...
user avatar
0 votes
2 answers
111 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 ...
user avatar
0 votes
1 answer
112 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; ...
user avatar
  • 185
1 vote
1 answer
91 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 ...
user avatar
-1 votes
2 answers
110 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 ...
user avatar
  • 115
1 vote
2 answers
76 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 ...
user avatar
4 votes
3 answers
249 views

Passing object or using the field

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
user avatar
  • 63
0 votes
1 answer
78 views

Should there only ever be one instance of a ViewModel object?

Assume a rather simplistic model: class Person{ static List<Person> LivingPersons String Name List<Person> Dependents } From this it can (hopefully) be seen that a single ...
user avatar
0 votes
1 answer
104 views

Pattern name to compare previous raw values to current values

I find myself applying a certain pattern again and again and I assume I am not the first one. I am looking for a name. In the environment I find myself in we get updates to values via an external ...
user avatar
  • 119
4 votes
2 answers
185 views

GoF Builder Pattern Applicability

The book Design Patterns: Elements of Reusable Object-Oriented Software says to use the builder pattern when The algorithm for creating a complex object should be independent of the parts that make ...
user avatar
-1 votes
3 answers
143 views

Chain of responsibility look alike but choose handler at runtime

Currently I have an structure of PopUps and I've been thinking to use Chain of Responsibility pattern, but the difference is a popup can back to previous one PopUp and also can go to any other PopUp. ...
user avatar
0 votes
1 answer
156 views

Python: Function pipeline with multiple return/input values, or use OOP? Best Practices?

I have a 'processing' function and a 'serializing' function. Currently the processor returns 4 different types of data structures to be serialized in different ways. Looking for the best practise on ...
user avatar
1 vote
0 answers
83 views

Visitor pattern with internal iterators

I'm trying to understand the following description of implementing the visitor pattern with an internal iterator. It is from the GoF's Design Pattern Elements of Reusable Object-Oriented Software book ...
user avatar
  • 119
0 votes
0 answers
69 views

Can someone suggest what pattern I used mistakenly and is it correct in this situation. Any alternative?

Client_1 uses --> IService_1 and thus Service1_impl public interface IService_1 { void DoTask_1(); } public class Service1_impl : IService_1 { private readonly IDepService_1_v1 ...
user avatar
  • 181
2 votes
1 answer
243 views

What is the name of this pattern / style?

We have a "workflow orchestration" system at work. It works something like this: You configure what to run (in a database table), such as: NameOfStepATHingToRun ="weather_data" ...
user avatar
0 votes
0 answers
81 views

Design pattern for intercepting requests to an API (Rule Engine)

I want to use a rule engine to centralize business rules. My rules require information not typically owned by systems that call the rules engine. I don't want to complicate these systems (System A and ...
user avatar
  • 587
1 vote
2 answers
94 views

Good OO design pattern for variant return type needs

I've got a validation function something like this (pseudo-code): public function validate(Thing thing) { if (thing.a != "a") { return false; // most of the time } if (...
user avatar
  • 175
1 vote
2 answers
98 views

Visitor design pattern usage

I have been implementing a software driver for an external (from my microcontroller point of view) chip communicating with my microcontroller over I2C. From the higher perspective the chip is a ...
user avatar
-1 votes
1 answer
792 views

How can I orchestrate multiple business tasks?

I have a WebApi backend with a Blazor WASM frontend. The application is split up into 3 main parts. Core, Infrastructure and Presentation. Basic onion architecture structure. Core.Domain Domain ...
user avatar
1 vote
1 answer
164 views

Why we don't use array of classes instead of Chain of Responsibility technique

I am new to SE. Recently I read about the Chain of Responsibility pattern, so basically what it does is: it creates a class that has some methods and also next class (next chain block), so when it ...
user avatar
-2 votes
2 answers
86 views

How would you create abstraction for event holding only Ids - references to other objects

class DomainEvent { } and then I have different events with following structure: class SomeEvent extend DomainEvent { private UUID orderId; private UUID orderlineId; private UUID productId; ...
user avatar
  • 520
-2 votes
1 answer
169 views

toppings in pizza factory?

Going through Head First Design Patterns, and their Pizza factory example, it seems that there is no room for specifying toppings. In general, if I have a process which contacts different APIs which ...
user avatar
  • 196

1
3 4
5
6 7
85