Questions tagged [design-patterns]
A design pattern is a general reusable solution to a commonly occurring problem in software design.
4,505 questions
-1votes
1answer
202views
Which pattern is suitable for this scenario?
I would like to refactor some code of a process that must perform a processing. The processing involves several steps, each of which can fail or go well. If successful, it must proceed to the next ...
2votes
3answers
121views
Is this an aggregate in DDD? Is it unnecessary to group objects as an aggregate if there are no invariants?
Below is a scenario that needs to be modeled using the Domain-Driven Design (DDD) approach. A Project can have Notes added to it. A Note cannot exist without a Project. A Note needs to be viewable ...
4votes
1answer
166views
Holding state in a service class in MVVM
In my SwiftUI app, I have a UpNextManager view model and a service class called UpNextService which contains many methods to read up next items from disk, write them to disk and much more. The service ...
3votes
3answers
445views
Is it a good idea to wrap node.js package functions in a micro-service architecture?
Our development team works with a micro-service node.js architecture. This means we work with a very large amount of repositories that currently each take care of their own dependencies. To avoid ...
3votes
1answer
153views
Deciding on granularity of SOLID's SRP
I am currently working in a project where we are utilizing kafka as a Message Queue. We have two use cases here, one is to consume the messages in parallel, no ordering of any kind required. And one ...
3votes
1answer
329views
why would one use the "Functional Options" pattern in go?
I just learned about the Functional Options pattern in golang. what are the benefits of using it over just allowing to pass a config struct and just overriding the default values provided in the ...
2votes
0answers
223views
How to encapsulate functions inside a library
I'm working on a project that uses an in-house library, which is also used by other projects. There are some classes and methods in other classes that are not used outside the library itself, is there ...
1vote
3answers
177views
How to handle authorization in CQRS
In a CQRS architecture, at least as implemented by Vaughn Vernon in IDDD_Samples, the query services lives in the application layer. But then where and how should authorization be handled? For example,...
3votes
3answers
228views
Repository returning multiple aggregates
A common DDD wisdom I encounter online is that your repository should not return more than one aggregate type. But I came across this passage from Vaughn Vernon's book "Implementing Domain-Driven ...
3votes
5answers
961views
What is the design pattern of a program that uses global arrays to store variables?
Specifically, I mean code structured in a way where storage is global. Bare with me, as my terminology is all over the place. If I want to create a variable, I "load" it into a global cache. ...
0votes
1answer
116views
What's the point of "use case optimal query" and partial aggregates in DDD?
In Vaughn Vernon's book "Implementing Domain-Driven Design", he talked about repositories that allows you to query for partial aggregates using a "use case optimal query": (from ...
2votes
3answers
210views
Aggregate with a huge list of value objects
I'm currently reading "Implementing Domain-Driven Design" while going through the code samples, but I'm having trouble modeling aggregates that stores a huge list of value objects. For ...
2votes
3answers
284views
How do I model this scenario so that it adheres to OOP principles?
I have a Slide class with subclasses referring to the different types of slides (IntroSlide, SummarySlide, etc.): abstract class Slide { String slideType; final String title; final String ...
21votes
5answers
4kviews
How manage inventory discrepancies due to measurement errors in warehouse management systems
I'm developing an enterprise-grade warehouse management application for a chemistry laboratory. A critical feature involves mixing multiple stock solutions to create new solutions based on predefined ...
1vote
3answers
262views
How to allow users to provide their own child classes in a factory design pattern in c++?
I am building a c++ project that will allow users to essentially model and create their own fleet of cars. Right now, the approach I have in mind is a Car Factory Class that will implement all of the ...