2

I have read in several places this following rule concerning Aggregates:

Entities in one aggregate can hold references to any other Aggregate Root, but never to an Entity or Value Object inside the other Aggregate.

What can go wrong if an Entity was holding a direct reference to an entity in another Aggregate root?

Can someone please explain why such rule is important? and preferably illustrate with an example, please?

1 Answer 1

5

The point of aggregate root is to encapsulate behavior of the whole through it's root. This simplifies the model, because you know any entity in aggregate will always be changed through only one entity, the root. By allowing entities to reference another entity, that is not a root in an aggregate, breaks this encapsulation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.