For an example see the source for the canonical Evans-approved ddd example, where the aggregate root Cargo class exposes several of its children, but the child entites are immutable.Ģ) Aggregate roots can hold references to other aggregate roots, they just can't change each other. So Order.LineItems is fine, as long as it returns an immutable collection of (publicly) immutable objects. The important thing is to make sure that all interactions with children are mediated by the aggregate root so that there's a single, predictable place to guarantee invariants. :)ġ) There's nothing wrong with accessing children of an aggregate root via simple, read-only properties or get methods.
I think I am misunderstanding the whole concept.
#Domain driven design repository full#
The customer class would be full of child manipulation methods then.
A huge entity I want to perform CRUD methods on. What if I have an Customer class with several addresses, contracts and even more child collections. Would I still create a repository method at the OrderRepository like "GetLineItemById"?Ĭurrently I don't think it's reasonable to have an immutable children.
How do I load just one of the 1000 line items? As far as I understand, a line item can only be accessed through the Order class and has a "local" identity. If I have an Order class an as aggregate root and 1000 line items. Domain driven design aggregate root repository