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
votes
1answer
34 views

Inject configuration files into the injector is it an antipattern?

I'm trying to design a system that inject configuration of each component into each class. project structure: |features --|component-a component-a.service.js component-a.config....
-4
votes
0answers
55 views

Factory method inside Value Object [closed]

I have a value object which is basically an input to the whole application, coming in via the URL (a web app). Let's call it SupplierId. It is fundamentally a string, with the caveat that there is a ...
4
votes
3answers
468 views

Pattern for endpoint that routes requests?

I am building a service that will push notifications to many other services. It has a couple of different notification types that each consumer may care about, but likely will not care about all of ...
7
votes
3answers
313 views

Pointers vs keeping indices of objects stored in a central (associative) array?

Until recently I used to think that it was preferred to reference objects by pointers or references than to keep objects in some sort of a central, authoritative array or dictionary and only keep ...
1
vote
3answers
205 views
+50

How to use abstract factory on interacting widgets

Context In many GUI frameworks, it is very common that widgets are placed in a container to arrange them visually in a window. For example, in Gtkmm, a window with a label and a button (side by side) ...
10
votes
4answers
22k views

Abstract Property In Base Class To Force Programmer To Define It

I'm coding with a state pattern for an embedded device. I have a base/abstract class called State and then each discrete(concrete) state class implements the abstract State Class. In the State Class ...
1
vote
3answers
1k views

How Design a program that must handle multiple "products" like in a production line

I have some problems figuring out how I should design an application. On a production line there multiple stations. The products will move from one station to the next. Each station will execute some ...
-3
votes
0answers
71 views

How to implement state machine to card games such as poker or russian poker?

These are my class designs: I also have Controllers where I can create table, create users add users to table, deal hands simulate user bets using PostMan (Above classes are game engine classes, I ...
6
votes
2answers
2k views

Loose Coupling Presenter to View in MVP

We work in a Java shop here and our web application uses an implementation of the MVP architectural pattern. Our manager comes from a .NET world, where he has been exposed to the MVVM design pattern. ...
6
votes
3answers
18k views

Call base inside overriden method

I know there are questions about calling the base method inside an overridden method such as this. But what if an overridden method only calls the base class? Is this bad/good deign? It just seems odd,...
-1
votes
0answers
28 views

Multiple data sync pattern [closed]

in my project I have to get two different data from the same source. The source is a stream, so data comes continuously and I have to update my copy. I'm not guaranteed that the I need will come with ...
0
votes
1answer
44 views

How to design an application for stalling file processing?

I have an application that is receiving a live stream of files, I am using active MQ for listening to the file arrival in s3. As soon as the file arrives in s3 my application downloads the file and ...
0
votes
1answer
41 views

ASP.NET Core - Using Partial Views inside a Modal window for my Add/Edit/View Details screens?

I've been developing .NET projects for the past 3 years, and on my recent web .NET projects, I've been using Partial Views for all the screens that contain Forms for Add/Update/Delete or other ...
-1
votes
3answers
176 views

Running series of steps depending on implementation

What is the "best way" to implement something like this: I have a list of steps that will be iterated and ran for an IContext instance. But, some steps will only apply to a specific instance ...
0
votes
1answer
187 views

Creating a internet gateway for bluetooth low energy device

I have a device that connect using Bluetooth - Low Energy. I would like it to be able to communicate with a server over internet using a smartphone as a gateway. As I approach this I am coming up with ...
0
votes
1answer
133 views

Does the builder/factories pattern apply to this problem?

I have the following code and I am not sure if the builder factory is the best approach to solve this code duplication. createA(a, b, c, e: {e1, e2}){ return{ a b c e } } ...
3
votes
1answer
88 views

Need technical advice about passing data through UINavigationController

First of all a small introduction, im relatively new to Swift and to programming in general, been doing it for the last year and loving every and each new thing of this vast world. My post is about ...
0
votes
1answer
47 views

Design class with different dependency requirements based on configuration

I’m struggling a bit to design the following class: It’s a service class with multiple methods. It depends on a http client interface which must be created in the factory method and can’t be passed ...
0
votes
1answer
92 views

How to combine data from multiple sources into the same object?

I've been running into a common pattern when requesting data from multiple sources: Have a list of objects from one source (e.g. a list of Cars) with an id property and a few other properties ...
0
votes
2answers
254 views

Is "error first" better than "if-else", why? [duplicate]

I have an eternal discussion in my work about why "error first" is "worng". In order to ensure what I try to tell with error first is the following code pattern: if condition: ...
17
votes
4answers
44k views

MVC and RESTful API service

MVC is pretty straightforward. There is a Model, a Controller and a View. When we create a website, it all come together as 'client sends REST keyword request to server -> the server matches the ...
0
votes
2answers
94 views

How to enforce matching, but unknown interfaces

I am challenging my OO design skills and started an ambitious project that is supposed to be highly reusable and extensible. It is supposed to be kind of a framework for evolutionary algorithms. Maybe ...
-1
votes
6answers
205 views

If it is a bad practice to use an interface if only one class will implement it, what is the purpose of IoC container?

Okay, first of all I understand the concept of IoC container! It's used to implement automatic dependency injection so you won't have to manually inject dependencies to class. It can automatically ...
-1
votes
3answers
133 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. ...
-5
votes
0answers
47 views

Should components communicate up or should a controller communicate down?

I have a situation where I am unsure which direction is the best practice. Using a simple example I have an an object that takes power lets say MyObject I have set it to take the interface ...
2
votes
2answers
245 views

How to use visitor pattern when objects change frequently

It is said that visitor pattern is applicable to problems where objects rarely change but we add actions on those objects more frequently. What if the objects are changing too though? For example we ...
1
vote
1answer
137 views

C# how to implement a factory class which doesn't require an argument passed to indicate objects type?

I currently working on a parser project in C# and have run into problem. I have an entity folder within my project and within it I have: Entity IEntity.cs (defines a contract for entity classes) ...
1
vote
1answer
120 views

Writing Event Process architecture for multiple event handler interfaces

I am working on Java program which will listen multiple kind of events from multiple sources and store information to multiple sinks. Each interface will have its own source to listen and own sink ...
-1
votes
2answers
133 views

Implementation of method differs only in one line

I have 2 implementation of the interface: public interface MyInterface{ void getCollectedData(MyData mydata); } public class MyImpl implements MyInterface{ public void getCollectedData(MyData ...
1
vote
4answers
178 views

How to make components communicate with each other

I have a simple setup where I've decided to reduce my overall OOP design and opt for lots of small individual components that I can add and remove from a particular object. The whole point of this was ...
0
votes
0answers
33 views

Which patterns use to design a turn based board game? [duplicate]

I am struggling to design a board game architecture since I am trying to keep it as generic as possible in order to improve its flexibility to extensions in case of new features, but doing that I'm ...
1
vote
1answer
148 views

How to correctly use the Factory Method pattern?

I'm currently re-designing my hobby project and I'm trying to apply what I've learned recently from design patterns. Summary for context: the project listens for TCP commands from my phone (using ...
-2
votes
2answers
104 views

How can we implement an incremental naming system?

Just like how Mac or Windows gives incremental names to new folders, how can we implement such a system in a database? Let's say I have currently 3 folders (default names) i.e., "untitled folder&...
-1
votes
1answer
78 views

Adapter pattern for formatting third party API responses

I've been refactoring some of my procedural code to OOP, and I'm wondering if using the adapter pattern is overkill in this case. Basically, I created a Order class. All class properties are a field ...
0
votes
1answer
749 views

The finer points of HMVC

I'm new to HMVC and whilst tutorials are great about dealing with the overall details of keeping modules separate and only letting controllers communicate, they aren't so great at explaining the ...
-2
votes
1answer
99 views

Design Patterns in C++: What is the best way to implement an interface with a generic type? [closed]

I would like to use a generic interface that has been implemented. I have two classes as such: class App { MainWindow<State> mainWindow; protected: virtual MainWindow<State> ...
5
votes
2answers
10k views

Unit Of Work with multiple database context

I have created an application (net core 2 & ef core) with Unit Of Work and Generic repository pattern. I used to have one database context but due to some business logic I had to create a second ...
0
votes
0answers
44 views

What is the best way to share data between two loosely coupled interfaces?

I have two interfaces: Camera and Computer. So far, each interfaces have multiple implementations in my codebase and they are loosely coupled (no implementations of Camera depends on any ...
1
vote
0answers
49 views

Design pattern for configurable factory sought

Apologies for the title, I'm sure there is some well-known phrase for it but I don't know it. I have a solution for a problem, but I'm not satisfied with and am seeking inputs to help me improve it. ...
0
votes
1answer
69 views

Best practice or patterns to couple complex custom objects to custom logic

In many project that grow more complex at a certain moment business rule editors, workflow editors, custom taxonomies and such enter the arena. In all of these a coupling is made between a complex ...
0
votes
1answer
110 views

Abstract Base Class decides which type of child class to create at runtime

I have an Abstract Base Class AbstractModel class AbstractModel { public: struct predictionStructure{}; virtual predictionStructure predict(CompanyLib::Matrix<double> data) = 0; std::...
12
votes
10answers
4k views

Best way to model a singleton in a relational database

When designing relational database schema for web applications, I often find a case where I end up creating a table just to contain one row, and only one row. It feels like that is the wrong way to ...
1
vote
4answers
405 views

Lead developer wants to use a micro-frontend design pattern. Are my concerns valid?

I'm a React developer at a large company working on an enterprise application which draws on a large amount of data, but performs a very specialized task and has only a handful of internal users. The ...
1
vote
4answers
614 views

Best way to display domain object summary information efficiently and in an OO way from a large inheritance tree?

I've provided only simplified code as it's more of an abstract design question. So I have many, many nested business/domain event objects, e.g. public class Event { //bunch of properties and ...
0
votes
1answer
82 views

How to expose C++ static library interface, extending Pimpl to an abstract interface

Until today I had a static C++ library with no separation between the public interface and internal headers. My other apps just linked to it, included the required headers, and used whatever they ...
1
vote
4answers
666 views

Managing multiple dynamic database connections

I'm working on a server, which you can pass some form of authentication as input (like connection string) and it will connect you to your database. So the DB connection is going to be dynamic. There ...
68
votes
4answers
44k views

Is it bad practice that a controller calls a repository instead of a service?

Is it bad practice that a controller calls a repository instead of a service? To explain more: I figure out that in good design controllers call services and services use repositories. But sometimes ...
1
vote
2answers
177 views

Concept/Design question: Alternatives to switch/conditional statements and Enums

I am practicing design patterns and OO concepts such as inheritance in java and I'm writing an application that represents a vending machine. I have two questions focused on ideal structure and design ...
0
votes
1answer
185 views

Should a UnitOfWork contain every Repository?

I'm trying to get the Repository/UnitOfWork pattern figured out. We're working on a project with EntityFramework and our DBContext contains 200+ tables. Right now our approach is to inject whatever ...
5
votes
2answers
1k 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 ...

1
2 3 4 5
84