Skip to main content
13 votes

DDD: Identifying aggregate root in a simple example application domain

Decision that what should be selected as an aggregate root is highly dependent on business rules of your application . If for example , there are two entities say A and B are highly dependent i.e. ...
Sahil Aggarwal's user avatar
9 votes

Can two different kind of aggregates in Domain Driven Design have actually the same unique Id?

The fact that you see DriverID as unique identifier for these micro-aggregates somehow suggest that they are not really independent aggregates but entities within the Driver aggregate, or even ...
Christophe's user avatar
  • 82.2k
9 votes

Unique Checks in Aggregates vs Database

My application allows for creation of an Item that is named by the user - and this name must be unique across all existing Items. Welcome to the world of set-validation. So two warnings before you ...
VoiceOfUnreason's user avatar
8 votes
Accepted

How to design the aggregate boundaries?

In the DDD perspective, Category, Product and Property are entities: they all correspond to objects that have their own identity. Option 1: your original design You made Category the root of a ...
Christophe's user avatar
  • 82.2k
8 votes

DDD - Aggregate inheritance and repositories, how to correctly design this situation?

it's kind of weird that I can have two repositories Get used to it. It's long been considered good practice to model your use cases explicitly. From the perspective of the application, it has a ...
VoiceOfUnreason's user avatar
8 votes
Accepted

DDD: Is an aggregate root responsible for deleting its child entities from their repository?

You should review Udi Dahan's arguments in Don't Delete - Just Don't. Of course, since then GDPR has become a thing. So you may want to include Forget Me as a domain concept. Is it ok to let the ...
VoiceOfUnreason's user avatar
8 votes
Accepted

DDD - Domain events vs application events

I'm considering two types of notifications For a number of reasons, the literature is pretty weak here; but I believe that you will find that the taxonomy of "domain events" and "integration events" ...
VoiceOfUnreason's user avatar
8 votes
Accepted

Many to many relations in Domain Driven Design

Just because you have a many to many relationship at a data or database level, doesn't mean it has to be represented in code. You should model for the relationships you care about or are useful to you....
Ryathal's user avatar
  • 13.5k
8 votes

Proper way to interact with child entities through aggregate root

So, after all this talking, could someone give me a thought on which of these two approaches is more suitable/appropriate for me to follow? Ruth Malan wrote: Design is what we do when we want to get ...
VoiceOfUnreason's user avatar
7 votes
Accepted

Handling aggregate root with deep object hierarchy

If you want to do it the right way as DDD suggests, then you are only allowed to change shape colour by using a method on the aggregate root directly and you cannot do it on the shape directly. The ...
Andy's user avatar
  • 10.4k
7 votes

DDD: deciding when to lean towards eventual vs transactional consistency

It seems you are overthinking this. The advice is illustrated in a few different and related use cases. 1. User Submits Proposal: Use case where the user is responsible for ensuring Proposal is ...
Vaughn's user avatar
  • 71
6 votes

Can an aggregate only ever consume commands and produce events?

aggregates consume commands and produce events: What is the foundation for this rule? In DDD, the Aggregates are the only one that are allowed to mutate the system state, so they are the only one ...
Constantin Galbenu's user avatar
6 votes
Accepted

DDD - How to avoid overlapping aggregate boundaries?

A good starting point for you would be Yves Reynhout's Evolving a Model, where he describes the modeling of appointment scheduling for healthcare. You might also want to review Greg Young's ...
VoiceOfUnreason's user avatar
6 votes
Accepted

DDD - operation on one aggregate that creates another aggregate

Your reasoning on creating the TaskLog as a separate aggregate is correct and makes sense. The responsibility of raising an event lies with the business logic, so prima facie, Option 1 would be the ...
Subhash's user avatar
  • 1,681
6 votes
Accepted

In DDD Aggregate + Event Sourcing, do Events happen before or after state changes?

Looking at it this way, it's not the Event that drives the change, nor is it the Aggregate that drives the change, but it's the decision that drives the change. Well, of course; this is what we refer ...
Filip Milovanović's user avatar
6 votes

Modeling invariants that requires data from multiple aggregates

I think the issue is that the domain model has a delete function. Deleting records from a database isn't really core business logic in the sense that you are modeling a business process. Instead, ...
Greg Burghardt's user avatar
5 votes
Accepted

Using Event Sourced Aggregate Roots with the Specification Pattern

Repository is set up to get ARs by their ID from the event store. That should suffice. If you need to query a collection of ARs from the repository you should use a specially designed Read model. ...
Constantin Galbenu's user avatar
5 votes

How to design the aggregate boundaries?

As I see it, you can solve this in one of two ways: Category is a special type of product This means for any given product in your database, it contains a foreign key pointing to the very same table ...
Neil's user avatar
  • 22.9k
5 votes

DDD - Domain events vs application events

After watching the Udi Dahan's video, I'm trying the following approach: I have an event store that contains the domain events, And I have an achievement store that contains what has been accomplished....
Stéphane Appercel's user avatar
5 votes

Confused about commands, domain events and external events in event sourcing

I'm a little confused about That's not your fault. The literature sucks. What people are really talking about is the way that information flows around our "domain model". Commands carry ...
VoiceOfUnreason's user avatar
5 votes

performance suggestions on Aggregate root containing thousands of child entities

Leaky Abstractions and Abstraction Bypasses When the abstraction breaks, and bypassing it feels prefferable, its time to fix the abstraction. Find a cheap way to speed it up, and put off actually ...
Kain0_0's user avatar
  • 16.6k
5 votes

Domain Driven Design - Updating and persisting aggregates

Ideally I just want to be able to update my aggregate and save it through my repository. Save the entire aggregate every time it changes regardless of which (possibly nested) fields change: Repository....
user3347715's user avatar
  • 3,244
5 votes
Accepted

Reusing aggregate root key across bounded contexts?

No, don’t reuse aggregate root keys for identifying different objects in different contexts ! Why? Because a Notificant is not a User. Maybe today, mostly users get notified. But tomorrow you may ...
Christophe's user avatar
  • 82.2k
5 votes
Accepted

DDD Aggregate reference differences

In your business domain, if Contract itself is used as frequently as Customer I think it is a hint that you should make Contract an Aggregate root as the same first class citizen as Customer. At the ...
ehe888's user avatar
  • 147
5 votes
Accepted

Where should I create my aggregate root? in api or frontend?

If you truly want to treat sale entities (with images included) as an aggregate in your domain model, you should not allow to GET or PUT sales and images individually, and use your SaleEntity model as ...
Doc Brown's user avatar
  • 220k
5 votes

Can two different kind of aggregates in Domain Driven Design have actually the same unique Id?

Yes. (Yes, they can, even when I think the more obvious approach will be to model your example using one aggregate, where the Driver entity is the aggregate root, see Christoph's answer.). But there ...
Doc Brown's user avatar
  • 220k
5 votes

When designing aggregates, can a child entity store another aggregate root ID?

OpeningHours is an aggregate root; it ensures its openings don’t overlap That is not what an aggregate root is. Look at it this way: if company A and B have the same opening hours, they have the same ...
Flater's user avatar
  • 59.5k
5 votes

Pattern / Architecture to implement State Machine with "steps" between states

I think the word you’re looking for is Transitions between states. So you would have a transition from state 1 to state 2, and this transition could be a state machine in itself. I’ve used this before ...
Adam B's user avatar
  • 1,660
4 votes
Accepted

DDD - Aggregate inheritance and repositories, how to correctly design this situation?

Your gut feeling is right, both Product and PurchasableProduct should be retrieved from the ProductRepository. This shouldn't be an issue, as one inherits from the other, say we add an extra table to ...
Ewan's user avatar
  • 84.4k
4 votes
Accepted

DDD integrating aggregate root with open host service (OHS)

But I heard that this is not quite good practice to inject services to aggregate root via method arguments or DI, but maybe it's OK? There are trade offs. Evans describes domain services as a ...
VoiceOfUnreason's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible