Open webdevilopers opened 3 years ago
Of course there is Option #4 and go full event-driven. An Event could create the Order and then a Saga / Process Manager fires a "checkCredit" Event etc. - but in this case I just wanted to focus on the "through another aggregate"-solution.
Came from:
In their book
Patterns Principles and Practices of Domain-Driven Design
@elbandit and @NTCoding show the following examples to create an aggregate through another aggregate by using a factory method.A great post on this topic by Udi Dahan:
A follow-up by @gedgei:
I wonder where these factory methods would live in a CQRS application with not a single
Domain Model
but aWRITE (Domain?!) Model
and aREAD (Domain also?) Model
.Let's take the last example where the
Account
holds the required credit.(1) WRITE MODEL (possibly event-sourced)
(2) READ MODEL) (rich model w/ e.g. Domain Value Objects, NOT a VIEW model with primitives only)
(3) Pass the READ model instead
Possibly related: