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
17
votes
2 answers

Using multiple services or multiple repositories within service?

Imagine we have two entities, EntityA and EntityB. Both entities have a repository to query the database, EntityARepository and EntityBRepository. There are also services for both of them, EntityAService and EntityBService. Now there is a method in…
tschaka1904
  • 1,303
  • 2
  • 17
  • 39
17
votes
3 answers

Replacing service layer with MediatR - is it worth to do it?

Do you think it might be reasonable to replace my service layer or service classes with MediatR? For example, my service classes look like this: public interface IEntityService where TEntityDto : class, IDto { Task
Konrad
  • 6,385
  • 12
  • 53
  • 96
17
votes
2 answers

Event Sourcing: proper way of rolling back aggregate state

I'm looking for an advice related to the proper way of implementing a rollback feature in a CQRS/event-sourcing application. This application allows to a group of editors to edit and update some editorial content, an editorial news for instance. We…
Enrico Massone
  • 6,464
  • 1
  • 28
  • 56
17
votes
4 answers

Is it safe to publish Domain Event before persisting the Aggregate?

In many different projects I have seen 2 different approaches of raising Domain Events. Raise Domain Event directly from aggregate. For example imagine you have Customer aggregate and here is a method inside it: public virtual void…
DmitriBodiu
  • 1,120
  • 1
  • 11
  • 22
17
votes
5 answers

Eventual consistency with both database and message queue records

I have an application where I need to store some data in a database (mysql for instance) and then publish some data in a message queue. My problem is: If the application crashes after the storage in the database, my data will never be written in the…
17
votes
4 answers

Should Value Objects Contain Technical Validation For Input Parameters?

As DDD practitioner advise, business rule's validations must be implemented inside domain objects (Entities, Value Objects and Domain Services) and follow their own context also somewhere i've read that we should put technical validations (such as…
Masoud Sedghi
  • 495
  • 1
  • 6
  • 19
17
votes
13 answers

Is it good practice to use domain objects as keys?

Is is good practice to use domain objects as keys for maps (or "get" methods), or is it better to just use the id of the domain object? It's simpler to explain with an example. Let's say I have Person class, a Club class, and a Membership class…
waxwing
  • 18,547
  • 8
  • 66
  • 82
17
votes
2 answers

DDD - Validation of unique constraint

In DDD you should never let your entities enter an invalid state. That being said, how do you handle the validation of a unique constraint? The creation of an entity is not a real problem. But let say you have an entity that must have a unique name…
W3Max
  • 3,328
  • 5
  • 35
  • 61
17
votes
3 answers

Best practice for DAO pattern?

I've seen a lot of codes use a service-dao pattern , I don't know the origin of this pattern . It force the front layer call service , then delegates some of the service task to dao. I want to ask : Does DAO layer do purely data access related…
Sawyer
  • 15,581
  • 27
  • 88
  • 124
17
votes
6 answers

DDD: Enum like entities

I have the following DB model: **Person table** ID | Name | StateId ------------------------------ 1 Joe 1 2 Peter 1 3 John 2 **State table** ID | Desc ------------------------------ 1 …
Chris
  • 7,229
  • 7
  • 41
  • 57
17
votes
2 answers

Is Repository Pattern with Domain Driven Design become Anti-Pattern?

First of all I want to clarify that I am new to Domain Driven Design and I am asking this question because I have read something called Anemic Domain Model. Most of the time I see following thing while working with Repository pattern. We have One…
dotnetstep
  • 17,065
  • 5
  • 54
  • 72
17
votes
2 answers

How to model entities that exists in all bounded contexts and that are a central part of the app?

I'm making an application using DDD principles. After thinking everything through as much as I can I'm down to start making my Bounded Contexts. I haven't set the final structure yet, but as of now my application will consist of the following…
cfs
  • 1,304
  • 12
  • 30
17
votes
3 answers

Framework suggestion for CQRS and EventSourcing

Are there any other Java frameworks for CQRS and Event Sourcing other than Axon Framework? I am specifically looking for Java based framework. Must support event sourcing.
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
17
votes
2 answers

CQRS - When to send confirmation message?

Example: Business rules states that the customer should get a confirmation message (email or similar) when an order has been placed. Lets say that a NewOrderRegisteredEvent is dispatched from the domain and is picked up by an event listener that…
Kimble
  • 7,295
  • 4
  • 54
  • 77
16
votes
1 answer

Update an entity inside an aggregate

I was reading a similar question on SO: How update an entity inside Aggregate, but I'm still not sure how a user interface should interact with entities inside an aggregate. Let's say I have a User, with a bunch of Addresses. User is the aggregate…
BenMorel
  • 34,448
  • 50
  • 182
  • 322