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,637
questions
225
votes
11
answers
31k
views
Why do we need so many classes in design patterns?
I am junior developer among seniors and am struggling a lot with understanding their thinking, reasoning.
I am reading Domain-Driven Design (DDD) and can't understand why we need to create so many ...
118
votes
6
answers
33k
views
What is a domain?
I see this term a lot in the context of software architecture ("domain-model", "domain-driven-design" etc.). I have googled it, but I get tons of different definitions. So what is it really?
103
votes
5
answers
16k
views
With all of these services, how can I not be anemic?
Where do we draw the line between delegation and encapsulation of business logic? It seems to me that the more we delegate, the more anemic we become. However, delegation also promotes reuse and the ...
98
votes
4
answers
31k
views
Rich Domain Models -- how, exactly, does behavior fit in?
In the debate of Rich vs. Anemic domain models, the internet is full of philosophical advice but short on authoritative examples. The objective of this question is to find definitive guidelines and ...
97
votes
6
answers
143k
views
Difference between a service class and a Helper class [closed]
I would like to know what differentiates a Service class from a utility class or a helper class?
A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper ...
89
votes
7
answers
112k
views
Application layer vs domain layer?
I am reading Domain-Driven Design by Evans and I am at the part discussing the layered architecture. I just realized that application and domain layers are different and should be separate. In the ...
86
votes
4
answers
7k
views
Programming and Ubiquitous Language (DDD) in a non-English domain
I know there are some questions already here that are closely related to this subject but none of them take Ubiquitous Language as the starting point so I think that justifies this question.
For ...
61
votes
4
answers
49k
views
DDD repositories in application or domain service
I m studying DDD these days, and I m having some questions concerning how to manage repositories with DDD.
Actually, I have met two possibilies :
First one
The first way of manage services I've ...
58
votes
6
answers
26k
views
Are DDD Aggregates really a good idea in a Web Application?
I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea.
...
57
votes
5
answers
9k
views
Is it still valid to speak about anemic model in the context of functional programming?
Most of DDD tactical design patterns belong to object-oriented paradigm, and anemic model describes the situation when all business logic is put into services rather than objects thus making them a ...
52
votes
8
answers
14k
views
Is domain driven design an anti-SQL pattern?
I am diving in the domain driven design (DDD) and while I go more deeply in it there are some things that I don't get. As I understand it, a main point is to split the Domain Logic (Business Logic) ...
51
votes
4
answers
25k
views
Where we should put validation for domain model
I still looking best practice for domain model validation. Is that good to put the validation in constructor of domain model ? my domain model validation example as follows:
public class Order
{
...
50
votes
5
answers
2k
views
How far should we rename code and data when end users nomenclatures change?
A long time ago we added a feature where our users could "Accept" an image after it was added to a workflow queue. Turns out, we used the wrong term, and users actually "Approve" the image.
Changing ...
50
votes
2
answers
20k
views
How do you handle shared concepts in a microservice architecture?
I am researching architectural patterns for an application I'm developing and a microservice approach seems like it would be a good choice but I am not sure how to handle interactions between the ...
50
votes
11
answers
30k
views
Best practice or design patterns for retrieval of data for reporting and dashboards in a domain-rich application
First, I want to say this seems to be a neglected question/area, so if this question needs improvement, help me make this a great question that can benefit others! I'm looking for advice and help from ...
48
votes
4
answers
30k
views
In DDD, is validation application logic, or domain logic?
Suppose that we are modelling a form using DDD; the form may have certain kind of business rules associated with it - perhaps you will need to specify an income if you are not a student, and you are ...
46
votes
5
answers
31k
views
How does a REST API fit for a command/action based domain?
In this article the author claims that
Sometimes, it is required to expose an operation in the API that inherently is non RESTful.
and that
If an API has too many actions, then that’s an ...
44
votes
8
answers
7k
views
Can a system be 100% Data Driven?
My new boss has been working on this project for many years. I've only been here a few weeks, but I am not sure it's possible. He would like to design a system that is "100% data driven".
So if we ...
43
votes
5
answers
59k
views
Is it good practice to use entity objects as data transfer objects?
I am wondering because if it is, why does Entity Framework not offer logic to create a new object with the same properties to transfer data between layers?
I use the entity objects that I generate ...
43
votes
3
answers
20k
views
What, in reference to DDD, is a bounded context?
When working through the book "Implementing Domain Driven Design" by Vaughn Vernon, I have been unable to gain a good grasp on what a bounded context actually is.
The book defines a bounded context ...
40
votes
1
answer
42k
views
Why database as queue so bad? [closed]
I've just read this article, and I'm confused.
Let's imagine 1 webapp and 1 distinct application acting as "worker", both sharing the same database.
Oh, I said "sharing"..but what does the article ...
38
votes
10
answers
49k
views
Using a GUID as a Primary Key
I generally use auto increment IDs as Primary Keys in databases. I am trying to learn the benefits of using GUIDs. I have read this article: https://betterexplained.com/articles/the-quick-guide-to-...
38
votes
5
answers
30k
views
Which layer do DDD Repositories belong to?
In his DDD book Evans promotes the idea of layered architecture, and in particular that the business logic should be confined to domain layer and separated from UI/persistence/other concerns. He also ...
38
votes
3
answers
30k
views
Implementing DDD: users and permissions
I am working on a small application trying to grasp the principles of domain-driven design. If successful, this might be a pilot for a larger project. I'm trying to follow the book "Implementing ...
37
votes
7
answers
10k
views
Do RESTful APIs tend to encourage anemic domain models?
I'm working on a project in which we are trying to apply both domain-driven design and REST to a service-oriented architecture. We aren't worrying about 100% REST compliance; it would probably be ...
37
votes
2
answers
25k
views
DDD: is it correct for a root aggregate to hold a reference to another root aggregate?
When following Domain-driven design (DDD), is it correct for a root aggregate to hold a reference to an internal entity that happens to be the root entity on a separate aggregate?
I believe this is ...
33
votes
4
answers
34k
views
Difference between Domain Driven Design and Clean Architecture
I have been studying Clean Architecture (CA) by Robert C. Martin and have found it quite useful in promoting architectural standards for large applications. Through implementation of a case study, I ...
32
votes
3
answers
10k
views
Conceptual mismatch between DDD Application Services and REST API
I'm trying to design an application that has a complex business domain and a requirement to support a REST API (not strictly REST, but resource-oriented). I have some trouble coming up with a way to ...
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 ...
31
votes
5
answers
12k
views
Pitfalls of Domain Driven Design with Entity Framework
A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar).
On the web there are also attempts by a few people to create ...
31
votes
2
answers
20k
views
DDD - Does an aggregate root's repository handle saving aggregates?
I am using a DDD-like approach for a greenfield module of an existing application; it's not 100% DDD due to architecture but I'm trying to use some DDD concepts. I have a bounded context (I think ...
31
votes
2
answers
9k
views
Domain-Driven-Design - external dependencies in the Entity problem
I'd like to start Domain-Driven-Design, but there are several problems I'd like to solve before starting :)
Let's imagine I have a Groups and Users and when user wants to join a group, I'm calling ...
31
votes
2
answers
10k
views
Best practices for serialization of DDD aggregates
According to DDD domain logic should not be polluted with technical concerns like serialization, object-relational mapping, etc.
So how do you serialize or map the aggregates' state without publicly ...
30
votes
9
answers
11k
views
When is primitive obsession not a code smell?
I have read plenty of articles recently that describe primitive obsession as a code smell.
There are two benefits of avoiding primitive obsession:
It makes the domain model more explicit. For ...
30
votes
3
answers
21k
views
DDD: Where to place domain event handlers?
Could you tell me your opinion that which layer is the right one to place domain event handlers in DDD? For example, I have application service to add a new contract and I'd like to send an email ...
29
votes
2
answers
15k
views
How exactly should a CQRS Command be validated and transformed to a domain object?
I have been adapting poor-man's CQRS1 for quite some time now because I love its flexibility to have granular data in one data store, providing great possibilities for analysis and thus increasing ...
28
votes
2
answers
4k
views
Is a Unit test considered brittle if it fails when the business logic changes?
Please see the code below; it tests to see if a person with Gender of female is eligible for offer1:
[Fact]
public void ReturnsFalseWhenGivenAPersonWithAGenderOfFemale()
{
var personId = Guid....
28
votes
1
answer
8k
views
How to choose between using a Domain Event, or letting the application layer orchestrate everything
I'm setting my first steps into domain driven design, bought the blue book and all, and I find myself seeing three ways to implement a certain solution. For the record: I'm not using CQRS or Event ...
27
votes
3
answers
12k
views
What is Domain Driven Development in practical terms? [closed]
I heard about Domain Driven Development from a developer in the area. He talked it up like it was just about the silver bullet to changing requirements.
I read the wiki. Still not too clear. What ...
26
votes
5
answers
4k
views
Do ORMs enable the creation of rich domain models?
After using Hibernate on most of my projects for about 8 years, I've landed on a company that discourages its use and wants applications to only interact with the DB through stored procedures.
After ...
24
votes
5
answers
21k
views
How to combine strict TDD and DDD?
TDD is about designing code, guided by tests.
Thus, typical layers aren't usually built upfront; they should slightly appear through refactoring steps.
Domain-driven design involves a lot of ...
24
votes
2
answers
29k
views
DDD - Are 'use cases' and 'application services' different names for the same thing?
I'm struggling a little bit with Domain Driven Design because there are so many names and concepts to grasp.
Today it striked me to know what is exactly the difference between an 'application service'...
24
votes
5
answers
9k
views
Unit Testing in a "no setter" world
I do not consider myself a DDD expert but, as a solution architect, do try to apply best practices whenever possible. I know there is a lot of discussion around the pro's and con's of the no (public) ...
24
votes
2
answers
7k
views
DDD CQRS - per-query and per-command authorization
Summary
Should authorization in CQRS/DDD be implemented per-command/query or not?
I am developing for the first time an online application using more or less strictly the DDD CQRS pattern. I bumped ...
23
votes
2
answers
18k
views
Exceptions in DDD
I'm learning DDD and I'm thinking about throwing exceptions in certain situations. I understand that an object can not enter to a bad state so here the exceptions are fine, but in many examples ...
23
votes
3
answers
8k
views
When using DDD and CRQS, should be exactly one event per command?
I am looking for a way to design a ddd application with convention over configuration.
Say an aggregate "Client" has a command defined "FillProfile". It will logically raise an event "ProfileFilled". ...
23
votes
2
answers
11k
views
Is there an elegant way to check unique constraints on domain object attributes without moving business logic into service layer?
I have been adapting domain-driven design for about 8 years now and even after all these years, there is still one thing, that has been bugging me. That is checking for a unique record in data storage ...
23
votes
4
answers
4k
views
How does persistence fit into a purely functional language?
How does the pattern of using command handlers to deal with persistence fit into a purely functional language, where we want to make IO-related code as thin as possible?
When implementing Domain-...
22
votes
8
answers
8k
views
Do immutable objects and DDD go together?
Consider a system that uses DDD (as well: any system that uses an ORM). The point of any system realistically, in nearly every use case, will be to manipulate those domain objects. Otherwise there's ...
20
votes
2
answers
1k
views
Anemic domain models and domain services injection
The anemic domain model is described as an anti-pattern in domain driven design by Martin Fowler. To have business logic on the domain models often domain services are used. But injecting domain ...