Questions tagged [domain-driven-design]

Domain-driven design (DDD) is an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts. Note that conceptual DDD questions are better to be asked at softwareengineering.stackexchange.com.

The premise of domain-driven design is the following:

  • Placing the project's primary focus on the core domain and domain logic
  • Basing complex designs on a model
  • Initiating a creative collaboration between technical and domain experts to iteratively cut ever closer to the conceptual heart of the problem.

Domain-driven design is not a technology or a methodology. DDD provides a structure of practices and terminology for making design decisions that focus and accelerate software projects dealing with complicated domains.

The term was coined by Eric Evans in his book of the same title: Domain-Driven Design: Tackling Complexity in the Heart of Software

Books

Sample Application

6728 questions
83
votes
3 answers

Having Separate Domain Model and Persistence Model in DDD

I have been reading about domain driven design and how to implement it while using code first approach for generating a database. From what I've read and researched there are two opinions around this subject: Have 1 class that serves both as a…
Adrian Hristov
  • 1,957
  • 2
  • 16
  • 22
82
votes
8 answers

CQRS Event Sourcing: Validate UserName uniqueness

Let's take a simple "Account Registration" example, here is the flow: User visit the website Click the "Register" button and fill out the form, click the "Save" button MVC Controller: Validate UserName uniqueness by reading from…
Mouhong Lin
  • 4,402
  • 4
  • 33
  • 48
81
votes
5 answers

DDD - which layer DTO should be implemented

I am learning about DDD so apologies if my question is naive. I think I need to use Local Data Transfer Object in order to display data to the users as a lot of properties are not part of any of Entity / Value Objects. However, I am not sure where…
user2105030
  • 831
  • 1
  • 7
  • 7
80
votes
6 answers

EF codefirst : Should I initialize navigation properties?

I had seen some books(e.g programming entity framework code first Julia Lerman) define their domain classes (POCO) with no initialization of the navigation properties like: public class User { public int Id { get; set; } public string…
78
votes
2 answers

How are Value Objects stored in the database?

I haven't really seen any examples, but I assume that they are saved inside the containing entity table within the database. Ie. If I have a Person entity/aggregate root and a corresponding Person table, if it had a Value Object called Address,…
kitsune
  • 11,516
  • 13
  • 57
  • 78
78
votes
4 answers

DDD - Persistence Model and Domain Model

I am trying to learn domain-driven design (DDD), and I think I got the basic idea. But there is something confusing me. In DDD, are the persistence model and domain model different things? I mean, we design our domain and classes with only domain…
ayk
  • 1,407
  • 2
  • 19
  • 26
74
votes
10 answers

Where to put global rules validation in DDD

I'm new to DDD, and I'm trying to apply it in real life. There is no questions about such validation logic, as null check, empty strings check, etc - that goes directly to entity constructor/property. But where to put validation of some global rules…
Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459
69
votes
2 answers

Iterator versus Stream of Java 8

To take advantage of the wide range of query methods included in java.util.stream of Jdk 8 I am attempted to design domain models where getters of relationship with * multiplicity (with zero or more instances ) return a Stream, instead of an…
Miguel Gamboa
  • 8,855
  • 7
  • 47
  • 94
69
votes
5 answers

DDD and MVC: Difference between 'Model' and 'Entity'

I'm seriously confused about the concept of the 'Model' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model almost acts like a database abstraction layer. The concept of 'Fat Model Skinny…
Nathan Loding
  • 3,185
  • 2
  • 37
  • 43
67
votes
5 answers

Validation in a Domain Driven Design

How do you deal with validation on complex aggregates in a domain driven design? Are you consolidating your business rules/validation logic? I understand argument validation and I understand property validation which can be attached to the models…
Todd Smith
  • 17,084
  • 11
  • 59
  • 78
65
votes
5 answers

Rest API and DDD

In my project using DDD methodology. The project has the aggregate(entity) Deal. This aggregate has many of use cases. For this aggregate I need to create a rest api. With standard: create and delete no problem. 1) CreateDealUseCase(name, price and…
stalxed
  • 1,143
  • 2
  • 9
  • 15
64
votes
2 answers

What is the difference between Command + CommandHandler and Service?

I have been reading about using Command objects to represent use cases that our domain exposes, and Command Handler objects to process those commands. For example: RegisterUserCommand RegisterUserCommandHandler But it looks exactly the same as…
Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
64
votes
5 answers

Doctrine Entities and business logic in a Symfony application

Any ideas / feedback are welcome :) I run into a problem in how to handle business logic around my Doctrine2 entities in a big Symfony2 application. (Sorry for the post length) After reading many blogs, cookbook and others ressources, I find that…
Koryonik
  • 2,728
  • 3
  • 22
  • 27
62
votes
7 answers

Is DDD a waste of time?

Googling "What kind of applications is DDD suitable for?" gave me the following answer: Probably 95% of all software applications fall into the “not so good for using DDD” categories. (see the article) So what is all the fuss about?!? The…
JacobE
  • 8,021
  • 7
  • 40
  • 48
61
votes
6 answers

Domain Driven Design and the role of the factory class

I'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (aggregate root) along with its associated entities and value objects. But…
Th3Fix3r