Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
3 votes
1 answer
330 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 ...
0 votes
0 answers
101 views

When, and why, to pass parameters by value?

For anything larger than a 64 bit integer, why would I want to pass by value? [Update] The question was closed, because it was not specific enough. One comment suggested that I specify a language. I ...
0 votes
1 answer
75 views

Does every Visited class have to be aware of the Visitor interface?

I'm taking another look at the pros and cons of the Visitor design pattern for a talk. There's obviously the issue that the Visitor has to be aware of every class it has specific handling for, but ...
-1 votes
0 answers
33 views

Observing changes in repository

I am developing a messaging application for iOS (although my question is not iOS related). I am using offline-first approach and I am adhering to the clean architecture design pattern. I currently ...
7 votes
3 answers
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 vote
2 answers
274 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
945 views

Do I use Repository or Service Object to Perform Logging?

I'm working in Java Spring, and I have typical service and repository layers. The repository grabs a JSON; passes it along to the service; service maps the repository response to a DTO. I also need ...
4 votes
3 answers
546 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 votes
0 answers
33 views

Alternative design pattern to a method containing a lot of methods? [duplicate]

I have a method in a class that takes in some variables and then runs a series of other methods in a pre-defined sequence. Below is a simplistic example: class MyClass: def ...
0 votes
1 answer
60 views

is there a two-way (bidirectional) observer pattern?

I have two classes. "System" and "Bluetooth". I want to have a really loose coherency between these two classes as they should be able to exist or not without depending on each ...
-1 votes
1 answer
83 views

State machine using SOLID principles. Connecting to real devices

I am trying to implement code for switching states of a couple laboratory devices. My considerations are: how should I link the state objects, state machine object and device manager object to follow ...
1 vote
2 answers
66 views

Calculate operation time and setuptime or costprice based on a variable set of parameters - Design Pattern?

I work in a production company where my colleagues calculate costprices based on 3D models and their respective operations. Apart from workactivities where a user has to insert an operation time and ...
0 votes
0 answers
36 views

Refactor conditional multiple AND OR operations? [duplicate]

I have a piece of code where two objects (incoming request object and a profile object) are to be checked for matching conditions. So the first method is as below where I check whether the profile ...
4 votes
3 answers
517 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 ...
-1 votes
1 answer
71 views

How to apply the Open-Closed design principle for different parameters in each class

I am a noob in design principles and design patterns, this might seem like a very silly question. Some classes in my code have the following structure (image linked): https://ibb.co/nrp1t2g As you can ...
1 vote
3 answers
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 ...
2 votes
1 answer
120 views

Best way to refactor service with too many dependencies

We are creating the backend for a web app using a sort of layered architecture. The service layer is supposed to handle the business logic and passing data to the repositories. This service layer is ...
6 votes
2 answers
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. ...
2 votes
3 answers
537 views

Why is the Command design pattern useful for game AI?

I'm trying to learn the Command design pattern and apply it to the game I'm working on. First I read about the general implementation, and I feel like I understand it pretty well. Now I want to know ...
5 votes
1 answer
807 views

Why do we implement the Command design pattern like this?

I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation. So I know we need to set the context by ...
5 votes
3 answers
1k views

Does the use of frameworks make it unnecessary to learn design patterns?

I don't want to say that is not necessary knowing design patterns. I just want to tell you my experience. I've used Spring frameworks for four years and another frameworks (JSF, Mybatis, Hibernate, ...
0 votes
1 answer
212 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 ...
31 votes
9 answers
7k views

Is extracting an interface just for testing purposes a code smell?

I will explain with an hypothetical example. Suppose that my domain is Cars. Everyone around the software, talks about cars. Car is the aggregate root of aggregate roots. For example, CAR table has ...
1 vote
1 answer
106 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
0 answers
71 views

Replacing TLD in image urls without changing the data

I have a flutter app which uses firebase/gcp as a backend. Files can be uploaded and stored on google cloud storage. In flutter I am using an UploadImage and UploadVideo model to store information ...
0 votes
1 answer
86 views

Plugin architecture vs Interface Segragation Principle (SOLID) [closed]

Uncle Bob's Interface Segragation Principle (ISP) tells us that many client-specific interfaces are better than one general-purpose interface. But plugin architecture in common case suppose to have ...
3 votes
1 answer
208 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 ...
-3 votes
0 answers
70 views

Utilizing OOP principles effectively to implement a graph algorithms demo application

I am currently working on writing a C++ app whose purpose it is to essentially "demo" various graph algorithms. At the moment, I have a very bare-bones Graph class working (which utilizes ...
1 vote
1 answer
58 views

How can one combine two system architectures, say client-server and repository architecture?

I have a situation where I think it would be best to combine two architectures but I am not sure if this is possible or that it is a good thing to do. By combining them I mean taking certain parts of ...
1 vote
1 answer
1k views

Is it right to have dependencies to my Viewmodel from data access layer and view layer

Context In my application I use the MVVM pattern. I'll have a ViewModel that can contains information of a student. This viewmodel is used to communicate between my view and model. I use ASP.net core ...
0 votes
2 answers
132 views

Best pattern/practice to execute a multi-step code generation process

I am working on a project that generates an API with the possibility of doing CRUD operations based on a high-level description of the resources that the user would like to have in an application. In ...
0 votes
0 answers
51 views

Splitting an object's state into multiple objects

I'm writing a virtual CPU, and I decided to create a class for each command, to make it easier to replace/add/remove commands without changing too much. The original idea was that ICommand would be ...
1 vote
4 answers
156 views

Modelling interactions (Domain driven design)

To use a dumb example, assume that particular users (labourers) can move boxes around. How would you go about representing that in your system in a semantic way that scales. I'm currently inclined to ...
0 votes
1 answer
162 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 ...
0 votes
2 answers
203 views

Which strategy to use to create object instances

I have this use case (I've simplified it): Each student can apply for one or multiple activities. As of now we only have Swimming activity onboarded on the system, but we expect to have more. Base ...
0 votes
2 answers
122 views

Maintainably converting flowchart ideas to an architecture

My team is communicating proposals for the interaction of several processes as a flowchart. I've been drafting a codebase architecture we can use as a starting point. There are two ways intended ...
0 votes
1 answer
786 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 ...
-1 votes
2 answers
192 views

Consuming Multiple resources from a single REST Service

I am developing a Spring Boot Application which consumes another REST service to get the User's Account information. The same service provides multiple operations like: GET: /userid/retrive -to get ...
5 votes
2 answers
12k 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 ...
11 votes
4 answers
8k views

"Factory Method is a specialization of Template Method". How?

Similarities and differences between the two: Template Method Relies on inheritance. Defines the steps of an algorithm, and leaves the task of implementing them to subclasses. Factory Method ...
2 votes
1 answer
752 views

How to do MVC in C++

I have a QT application with a window of OSG written in C++. I want to implement the app using MVC design. The application allows you to add markers to OSG model and it is using QT to edit the markers....
0 votes
1 answer
106 views

Dealing with multiple application instances

I'm developing an application (Java & JavaFX) that writes/reads data (a file). The problem is I don't want to restrict user to run only one instance (of my app) at a time, as I really can't think ...
0 votes
1 answer
114 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 ...
2 votes
1 answer
169 views

What is the best way to compartmentalize complex logic problems?

I am working on a problem with lots of if-then-else calculations. I am trying to compartmentalize the logic to make it more maintainable and less error prone. But, as I try options, I don't see what ...
1 vote
1 answer
280 views

MVC-like architecture: Model-Controller communication of results/status

I'm struggling on designing a solid architecture for my project. In particular, I don't know how to handle the communication between the models and the controllers. My goals are: Following the ...
17 votes
5 answers
3k views

What is the meaning of "inversion" in Dependency Inversion design principle?

I'm reading about design patterns. I know what this principle does. High-level and low-level classes depend on abstractions. But why we say this is inversion?
1 vote
2 answers
127 views

Difference between Strategy pattern and Repository pattern

I found the following definition of Repository Pattern: Repositories are classes or components that encapsulate the logic required to access data sources. They centralize common data access ...
-2 votes
1 answer
80 views

Are there real examples of using reflection design pattern to achieve partial deployment? [closed]

This site mentions such thing: http://software-pattern.org/Reflection. It says that it is possible to replace part of the application behaviour dynamically. Does it mean that we can achieve partial ...
2 votes
2 answers
318 views

The motivation behind the Factory Method design pattern

I'm learning about the Factory Method Desing Pattern and I'm having a hard time to understand exactly what it tries to solve and how. Let's first introduce the example that Wikipedia uses to have a ...
0 votes
1 answer
112 views

Design an extensible permissions model in database

I’m trying to model a system with Users, Permissions and Products. The main goal is to have a way of checking if a User has a specific Permission in order to allow or deny other system operations. So ...

1
2 3 4 5
85