I have two aggregate roots and two non aggregate root entities:
I know, that the relation D -> B
breaks DDD principle.
I heard, that in the most cases the solution is to make the referenced entity a new aggregate root.
But is making B to a new aggregate root really an option if B is a real child of A (B can not live without A)?
I agree with you, sometimes it just doesn't make sense to separate one entity from its aggregate, because it fits so naturally in it. This is one of the reasons why I'm not totally sold on the "small aggregates" approach that some recommend.
In such a case, what you can do is get a reference to B by traversal of an instance of A instead of getting it directly. After all, if B can't exist without A, there's no reason objects outside of the aggregate should know about a particular B and not know about its A.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With