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
16
votes
4 answers

Where should enums live in an MVC project structure?

I'm using .NET MVC 3 Code-First approach. My domain have a entity called Question, this entity have a Score property that is Byte and I want to replace that property to an Enum and name this Enum to Score where I can set the values from 0 to…
Acaz Souza
  • 8,311
  • 11
  • 54
  • 97
16
votes
3 answers

Application Service Layer: Unit Tests, Integration Tests, or Both?

I've got a bunch of methods in my application service layer that are doing things like this: public void Execute(PlaceOrderOnHoldCommand command) { var order = _repository.Load(command.OrderId); order.PlaceOnHold(); …
Josh Kodroff
  • 27,301
  • 27
  • 95
  • 148
16
votes
3 answers

In DDD, what are the actual advantages of value objects?

I have gotten so far that I understand entity objects have an ID while value object have not, but in the most common example you have the person entity that have a address value object attached to it. What is the big advantage of creating a separate…
terjetyl
  • 9,497
  • 4
  • 54
  • 72
16
votes
2 answers

How granular should a domain event be?

I am wondering how granular should a domain event be? For example I have something simple, like changing the firstName, the secondName and the email address on a profile page. Should I have 3 different domain events or just a single one? By coarse…
inf3rno
  • 24,976
  • 11
  • 115
  • 197
16
votes
1 answer

Dealing with nested aggregates in DDD

I'm just getting started in DDD, and I'm having some trouble figuring out how to accommodate the relational nature of my data. I have what I believe would be considered my aggregate root, but the aggregate also has an aggregate of its own. Not…
Josh Anderson
  • 5,975
  • 2
  • 35
  • 48
16
votes
3 answers

How should I start DDD?

What is the best way to start Domain Driven Design? What are the recommended resources? EDIT: I mean, I'd like to know how to start learning DDD (the same way as to start TDD by reading K. Beck).
rafek
  • 5,464
  • 13
  • 58
  • 72
16
votes
3 answers

Generic repository to update an entire aggregate

I am using the repository pattern to provide access to and saving of my aggregates. The problem is the updating of aggregates which consist of a relationship of entities. For example, take the Order and OrderItem relationship. The aggregate root…
16
votes
3 answers

Should DTO and Entity both have input validations

I have a WCF layer and my Domain Model is behind this WCF layer. I am using Nhibernate as an ORM tool and all my business logic/ Data Access etc will be behind this WCF layer. I am exposing DTO to my clients. I have below questions 1) Should i…
Sarvesh
  • 269
  • 1
  • 2
  • 10
16
votes
3 answers

Can we use REST + Event Sourcing + CQRS together

I understand the basics of REST + Event Sourcing. I never worked on a strict RESTful API and not either in any Event Sourcing project. Can someone explain if both can be used together? As in event sourcing, the client send events, does this mean…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
16
votes
2 answers

Functional Programming + Domain-Driven Design

Functional programming promotes immutable classes and referential transparency. Domain-driven design is composed of Value Object (immutable) and Entities (mutable). Should we create immutable Entities instead of mutable ones? Let's assume, project…
Mik378
  • 21,881
  • 15
  • 82
  • 180
16
votes
3 answers

DDD: aggregate root question

Let's say i got 2 entities - Foo and Bar. Foo is an aggregate root and contains Bar. As far as i understand, it should look like this: public class Foo{ private readonly Bar Bar; } I want to provide functionality for users to choose Bars for…
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
16
votes
6 answers

DDD - Modifications of child objects within aggregate

I am having some difficulty working out the best way to handle a fairly complex scenario. I've seen quite a few similar questions, but none addressed this scenario to my satisfaction. An Order (aggregate root) is created with multiple OrderLines…
Cork
  • 722
  • 6
  • 20
15
votes
2 answers

DDD and the use of Getters and Setters

I've read a few articles/posts regarding the use of Getters and Setters, and how they help to defeat the purpose of encapsulation in domain model objects. I understand the logic behind not using setters - you are allowing client code to manipulate…
Chris
  • 7,996
  • 11
  • 66
  • 98
15
votes
6 answers

In Domain-Driven Design, can you use your domain entities in your UI?

In many leading DDD projects, especially MVC style, I see the UI using display objects that mirror domain entities, rather than using those domain objects directly. This style is obviously for decoupling and separation of concerns, and I personally…
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
15
votes
1 answer

DDD: How to divide application to Bounded Contexts besides e-commerce sample?

We have a pretty big application here and I considering to refactor it a little bit to follow DDD guys guidance. For now the number one issue with it is Bounded Contexts and Context Maps. Maybe I just don't grok it, but it seems to me just…
Artem Tikhomirov
  • 21,497
  • 10
  • 48
  • 68