Questions tagged [domain-driven-design]
Domain-driven design (DDD) is an approach to develop software for complex needs by connecting the implementation to an evolving model.
1,678 questions
1
vote
1
answer
115
views
How should I design a password reset flow when the PasswordService depends on UserRepository (email vs ID)?
I’m working on a three layers architecture backend (Laravel).
Here’s the context:
I have a PasswordService responsible for updating a user’s
password.
and a Otpservice responsible for verifying/...
1
vote
1
answer
225
views
How should domain models be designed — rich domain models with encapsulated logic vs. anemic models with separate service/util layers?
I'm learning Domain-Driven Design (DDD) and studying different architecture patterns, and I’ve come across two seemingly conflicting design philosophies around domain modeling.
1. Rich Domain Model ...
0
votes
2
answers
203
views
Keeping the impact of changes low when moving shared domain objects into a library
I’m refactoring a microservice project where multiple services share the same domain objects. Over time, these objects have diverged across services, causing inconsistencies.
To solve this, I plan to ...
1
vote
2
answers
267
views
How to Handle Data Persistence In Domain Driven Design
I am currently reading about domain-driven design and n-tier architecture with a service layer, and comparing them to try to understand how each architecture is executed.
For n-tiers (specifically 3-...
0
votes
2
answers
177
views
How could I map a complex DTO to a Domain Aggregate in a Repository?
I'm working on a TypeScript application designed with DDD and using layered architecture. My infra layer has a repository that fetches a complex, nested DTO. My current implementation maps this DTO ...
2
votes
2
answers
154
views
When using Clean Code with Ports and Mappers: which layer declares the Entity (Aggregate) factory interface and which one implements it?
So I was reading Eric Evans DDD book and one point that was not clear to me is which Layer (in case of using Clean Code) should be reponsible to:
define the interface contract for an Entity (...
1
vote
3
answers
472
views
Practicing DDD from the biggest modules to the smallest widgets
I have a frontend project using VueJS and TS and I structured it using DDD. So far, I have some modules (bounded contexts, domains - use the term you prefer) which are used in two ways: some modules ...
4
votes
2
answers
329
views
Managing Growth in Microservice Architecture: Is Modular Monolith the Solution?
Our team of 5 members are managing a microservice architecture that currently includes around 200 Java Spring boot microservices, with approximately 50 new services being added each year. We follow ...
5
votes
3
answers
667
views
How to get rid of Mappers and make objects build themselves?
I am having a really hard time deciding where to instantiate my entities in the refactoring I am making. The project was built with DDD and it's layered: it has the infra, domain and app layers. In ...
5
votes
2
answers
232
views
Tree model in Domain Driven Design
A site is composed of pages.
Each page is either a root page or the
child of another page, forming a parent–child hierarchy.
The page tree has a fixed maximum depth.
When relocating a subtree:
The ...
4
votes
4
answers
248
views
Modeling superstate and substate combinations in DDD
I am designing an analytics application using domain driven design and test driven development.
I am having difficulty modeling the following requirement:
The application shows a workitem's state. ...
1
vote
2
answers
158
views
Dividing an HR Application into Bounded Contexts: Understanding How to Split a Domain into Multiple Models
I’m trying to understand bounded contexts by trying to apply them to an example HR application. According to a book called Patterns, Principles, and Practices of Domain-Driven Design (PPPDDD), context ...
2
votes
3
answers
332
views
DDD and Domain Models with a Web Api PUT / POST
The company I'm working at has strict policies that insist that all business logic is contained in Domain Models as part of DDD.
I can see how this approach could work well for something like a ...
0
votes
1
answer
168
views
How do I encapsulate domain logic and preserve state in DDD+Clean Architecture?
(For context I am developing in Angular)
Historically my applications have tended towards the layered architecture that the Angular fraemwork leads you into.
However I feel that the next application I ...
3
votes
5
answers
217
views
DDD - When a single physical entity in the problem space is represented as different concepts in code, how to link them together?
When a single physical entity means different things in different contexts, DDD principles recommend creating different entities in each bounded context.
This is an example taken from the book "...
3
votes
3
answers
255
views
Is it good DDD practice to hide all the aggregate methods behind domain services?
I'm working on a DDD-based system and was researching the best way to handle domain services and keep business logic consistent.
During my research, I came across this insightful quote from Steve ...
1
vote
0
answers
85
views
DDD infrastructure layer project type
I’m working on a DDD-based architecture using WPF. Currently, my Domain, Application, and Infrastructure layers are all implemented as .NET Standard projects, though I’m not certain if that’s the best ...
-1
votes
1
answer
78
views
Complex domain problem to be modeled with DDD
There is a case management application.
New requirements want to add statuses to cases.
The case will go through a series of statuses until completion.
Each case belongs to a case type. There are many ...
5
votes
2
answers
173
views
Modeling invariants that requires data from multiple aggregates
I want to model the organizations and users using DDD. I have the following aggregate roots:
Users
Can join multiple organizations
Can join at most 100 organizations
Can only be deleted when it is ...
3
votes
2
answers
194
views
How to segregate and name application services in DDD?
Below is an example scenario that can be used to illustrate your answer.
Let's say there is a CoffeeMachine aggregate with a set of methods similar to the following:
Methods used by admins.
...
1
vote
1
answer
192
views
How to map same name entities between domains in DDD?
I am working on the migration of a project from desktop to web. I am using VueJS 3 (composition API). Since this project has lots of modules, I thought about using DDD on the frontend for organization ...
1
vote
1
answer
138
views
Is it valid for two small aggregates to have the same root in DDD?
I have a data model with the following relationships:
Shipment 1 --- * ShipmentLine 1 --- * Component
I have two use cases around which I am trying to create a domain model. The use cases are:
...
2
votes
3
answers
168
views
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 ...
3
votes
2
answers
2k
views
What data type should a repository return?
In domain driven design, repositories are created for aggregate roots only. Does this mean that all repository methods should return an instance or a collection of the aggregate root for which the ...
0
votes
3
answers
771
views
Repository interfaces returning DTO in clean architecture used by query handlers
Repository interfaces are often defined in the Domain layer. This makes sense for command handlers, which call repository methods and return nothing. But what about query handlers that call repository ...
1
vote
2
answers
238
views
How to persist an entity corresponding to a polymorphic association table in Domain-Driven Design?
A polymorphic association table is a database design pattern that allows a single table to associate with multiple other tables, where the related tables can be of different types.
Scenario: Multiple ...
0
votes
1
answer
158
views
Where to put the application service interfaces in Domain Driven Design?
Let's say a project has an application layer and a domain layer.
AFAIK services implemented in the application layer execute use cases.
The methods defined in the services often contain ubiquitous ...
0
votes
2
answers
112
views
Where to put notification templates in Domain Driven Design?
I have a project with four layers:
Domain
Application
Infrastructure
Presentation
I have an email service interface in the Application layer. It takes an interface parameter called ...
1
vote
3
answers
315
views
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,...
3
votes
3
answers
402
views
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 ...
0
votes
1
answer
247
views
storing aggregates as json in postgresql all in one table
I am trying to decide what the best way of storing my data would be. I want to build a cqrs application where I also apply DDD principles like aggregates in the command side. I started with with ...
3
votes
5
answers
1k
views
What is the root cause of a proliferation of "null checks"?
I work with a lot of Groovy code. One feature of the language is the "safe navigation operator" (?), which I think of as an inline null check. There are many things about Groovy that I like, ...
0
votes
1
answer
249
views
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 ...
2
votes
3
answers
320
views
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 ...
3
votes
3
answers
313
views
Aligning domain model to data model. Is my data representation wrong?
Engineering Community,
I am currently writing my bachelor's thesis on microservices and DDD (this is not the actual topic, but it is part of it). The language I am writing in is Rust, but that is ...
1
vote
3
answers
419
views
Can an aggregate just depend on the ID of another aggregate for its own identity?
I started writing my application with a very understandable assumption that every Aggregate should be represented by a root entity that has its own ID (a surrogate key). But I think I have found a ...
1
vote
1
answer
327
views
Does my code follow DDD principles?
I'm trying to model P2P crypto trading using DDD and I'm having trouble modeling the lifecycle of sell orders. Lifecycle:
Some trader-seller creates an order.
Some trader-buyer responds to it.
Buyer ...
2
votes
2
answers
784
views
How should I implement data access with jpa to meet Clean Architecture/DDD
For the last few days I'm searching any information about compatibility of JPA and Clean Architecture/DDD. I found next ideas for decoupling application from hibernate.
Do not use @ManyToMany or @...
4
votes
2
answers
298
views
How to untangle bounded contexts after a team ownership reorganization?
This is inspired by Eric Evans' presentation about bounded contexts when doing Domain driven design.
In his presentation he presents a case where a bank has initially 2 teams that manage 2 bounded ...
1
vote
0
answers
83
views
Best practice: slightly different logic on multi mapping endpoint
Suppose I've got a spring controller as follows:
⋮
@RestController
public class MyController {
⋮
@PostMapping(value = { "publicAPI/addItem", "internalAPI/addItem" })
...
0
votes
2
answers
320
views
DDD: How to update a domain model with a lot of fields
Let's say there is a domain model:
@Table(name = "room")
@Getter
@FieldNameConstants
@AllArgsConstructor(onConstructor = @__({@PersistenceCreator}))
public class HotelRoom extends ...
0
votes
3
answers
499
views
Do I really need this many (DTO) types for mapping a simple object to CRUD & database?
Say I'm building my own backend framework (really I'm just learning) and I have a simple class:
class User {
String email
String passwordHash
Date birthdate
Int getAge() {
...
6
votes
3
answers
1k
views
Hexagonal Architecture + Domain Driven Design. How to perform a correct implementation?
Currently, I am trying to implement these two architectures together with Java and Spring (although technology shouldn't matter I think).
But I'm encountering problems getting them to work together.
I ...
1
vote
2
answers
205
views
Decoupling UIs from Domain logics | Clean architecture
I've been reading articles on Hexagonal, Onion, Clean Architectures, and other Domain-Driven Designs. A common theme they emphasize is decoupling components. From what I gather, this means the UI ...
0
votes
1
answer
338
views
How to Model Parent-Child relationships outside of Aggregates
I am developing an application with many Parent-Child relationships which are leaving me with some modeling questions. Before I ask, let me give you some context:
No aggregates
While I am trying to ...
-1
votes
1
answer
128
views
Data Driven UI - event handling
Currently in our web app, we have forms which define model and view in JSON (in-house library) on the client side. Example:
And there is a component for each form, which has
event handling logics ...
0
votes
1
answer
393
views
How to share transaction across multiple repositories in DDD?
We are trying the Domain Driven Development (DDD) while working on a project.
We've got a Product aggregate.
We've got a ProductRepository to load/save Products.
We've also got a Timeline aggregate, ...
0
votes
2
answers
128
views
Modeling value object when fields' existence depends on state of other fields
I am practicing tactical DDD and having trouble as exemplified below. Fundamentally, whether some fields of the value object should be nullable depends on another field of the same value object. ...
1
vote
1
answer
93
views
Aggregate design for a fuel tank with deliveries and fill level readings
So I've got a rather simple, mostly crud application I want to use DDD with, to learn/practice it. I wonder about aggregate design regarding a fuel tank entity. Each tank stores fill level readings (...
5
votes
3
answers
383
views
How to handle events representing cross-domain knowledge
I've been looking at DDD lately as part of playing with Spring Modulith, and I'm getting hung up a bit on how to approach events which cross between contexts.
To provide a concrete example based on a (...