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
21
votes
3 answers

CQRS and CRUD screens

One of the basic tenets of CQRS, as I understand it, is that commands should be behaviour-centric, and have a value in the business or the UL, and not data-centric, ie., CRUD. Instead of focusing on updating a customer, we have commands like…
blockhead
  • 9,655
  • 3
  • 43
  • 69
21
votes
5 answers

DDD with EF Code First - how to put them together?

I am learning DDD development for few days, and i start to like it. I (think i) understand the principle of DDD, where your main focus is on business objects, where you have aggregates, aggregates roots, repositories just for aggregates roots and so…
Catalin
  • 11,503
  • 19
  • 74
  • 147
21
votes
4 answers

Where to convert a DTO to ViewModel?

I've inherited an MVC2 project using a pretty standard and decently well kept DDD pattern. I've been doing a lot of reading on the whole DTO/ViewModel debate as well. Currently our DTOs are often used like ViewModels. It honestly doesn't make a…
20
votes
3 answers

Where to put business logic in DDD

I'm trying to figure out the best way to build an easily maintainable and testable architecture. Having gone through several projects, I've seen some pretty bad architectures and I want to avoid making future mistakes on my own projects. Let's say…
Vex
  • 1,179
  • 3
  • 15
  • 24
20
votes
4 answers

Techniques for dealing with anemic domain model

I've read some of the questions regarding anemic domain models and separation of concerns. What are the best techniques for performing/attaching domain logic on anemic domain objects? At my job, we have a pretty anemic model, and we're currently…
Andy White
  • 86,444
  • 48
  • 176
  • 211
20
votes
3 answers

Practical usage of the Unit Of Work & Repository patterns

I'm building an ORM, and try to find out what are the exact responsibilities of each pattern. Let's say I want to transfer money between two accounts, using the Unit Of Work to manage the updates in a single database transaction. Is the following…
BenMorel
  • 34,448
  • 50
  • 182
  • 322
20
votes
3 answers

Validation and DDD - kotlin data classes

In Java I would do validation when creating constructor in domain object, but when using data class from kotlin I don't know how to make similar validation. I could do that in application service, but I want to stick to domain object and it's logic.…
Surrealistic
  • 278
  • 1
  • 2
  • 8
20
votes
3 answers

Command Validation in DDD with CQRS

I am learning DDD and making use of the CQRS pattern. I don't understand how to validate business rules in a command handler without reading from the data store. For example, Chris wants to give Ashley a gift. The command might be…
chris
  • 6,653
  • 6
  • 41
  • 54
20
votes
2 answers

DDD Invariants Business Rules and Validation

I am looking for advice on where to add validation rules for domain entities, and best practices for implementation. I did search and did not find what i was looking for, or i missed it. I would like to know what the recommended way is for…
20
votes
5 answers

DDD: Entity identity before being persisted

In Domain Driven Design, one of the defining characteristic of an Entity is that it has an identity. Problem: I am not able to provide a unique identity to Entities on instance creation. This identity is only provided by the repository once the…
Dave New
  • 38,496
  • 59
  • 215
  • 394
20
votes
4 answers

Domain driven design and transactions in Spring environment

I used to design my application around anemic domain model, so I had many repository object, which were injected to the big, fat, transaction-aware service layer. This pattern is called Transaction script. It's not considered a good practice since…
semberal
  • 2,204
  • 1
  • 21
  • 21
20
votes
8 answers

If you are forced to use an Anemic domain model, where do you put your business logic and calculated fields?

Our current O/RM tool does not really allow for rich domain models, so we are forced to utilize anemic (DTO) entities everywhere. This has worked fine, but I continue to struggle with where to put basic object-based business logic and calculated…
Beep beep
  • 18,873
  • 12
  • 63
  • 78
20
votes
1 answer

App-level settings in DDD?

Just wanted to get the groups thoughts on how to handle configuration details of entities. What I'm thinking of specifically is high level settings which might be admin-changed. the sort of thing that you might store in the app or web.config…
Paul
  • 35,689
  • 11
  • 93
  • 122
19
votes
4 answers

Entities across bounded contexts in Domain-Driven Design

I am trying to understand how entities operate in multiple bounded contexts. Given an Employee of a Company. In (for example) the Human Resources context, this person has a name, surname, address, salary reference number, and bank account. But in…
Asher
  • 1,016
  • 1
  • 6
  • 20
19
votes
6 answers

Is it possible to use DDD and BDD together?

I like the middle-out development that is achieved with DDD. Development is driven by domain, the most solid part of application. We don't depend on infrastructure, persistence and presentation. That sounds good. But it has no business value. Here…
Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459