Is it correct for a root aggregate to hold reference to another root aggregate?

Is it correct for a root aggregate to hold reference to another root aggregate?

DDD: is it correct for a root aggregate to hold a reference to another root aggregate? When following Domain-driven design (DDD), is it correct for a root aggregate to hold a reference to an internal entity that happens to be the root entity on a separate aggregate?

Can a child entity hold reference to aggregate root?

No, generally child entities should not hold reference to aggregate roots. Aggregate root is the entry point to the entire aggregate and must maintain its consistency boundaries. This means, that every change to the aggregate must be forwarded through the root entity (in oop by calling methods of root entity).

What is the role of aggregate root in OOP?

Aggregate root is the entry point to the entire aggregate and must maintain its consistency boundaries. This means, that every change to the aggregate must be forwarded through the root entity (in oop by calling methods of root entity). Aggregate root can return references to child entities, but they must be transient.

Can a entity be shared across many aggregates?

Since the premise of DDD is that the Aggregate is the entry point, you would be able to load A, modify entity E through it, all the while silently violating invariants from B (that you didn’t load). See the answer from Greg Young here : http://domain-driven-design.3010926.n2.nabble.com/Can-an-Entity-be-Shared-across-many-Aggregates-td7579277.html

Why is my code missing the aggregate root?

The code above is missing the real aggregate root. There’s also the inevitable question of validation – if the customer object isn’t willing to accept a name with a space in it, should we throw an exception? That would prevent an invalid entity from being saved, which is good.

Which is the only member of an aggregate?

Each AGGREGATE has a root and The root is the only *member* of the AGGREGATE — this verbage implies that the root is property on the Aggregate. But in all of the examples, it’s the other way around: the root contains properties that are aggregates.

What is an aggregate root in a repository pattern?

10 Answers 10. In the context of the repository pattern, aggregate roots are the only objects your client code loads from the repository. The repository encapsulates access to child objects – from a caller’s perspective it automatically loads them, either at the same time the root is loaded or when they’re actually needed (as with lazy loading).