Contents
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’s the difference between aggregates and entities in DDD?
Here are some thoughts on distinctions between aggregates and entities in domain-driven design (DDD), in response to some good questions Harry Brumleve asked me via email. I’ve always had problems with Aggregates vs. Entities. Is it that Agg’s are transactional boundaries that expose behaviors (methods) that the entities they contain may perform?
What do you call entity that acts as aggregate root?
I have an entity that acts as an aggregate root, let’s call it Root. This entity refers to a collection of child entities of the type Child.
How are entities and aggregates used in design?
I find the aggregate root concept helpful though, since a single entity typically takes that responsibility. To your point, if entities aren’t used across aggregate types, aren’t you really using the behaviors of the aggregates to express your model and the entities to express the arbitrary design of a particular aggregate?
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.
How is an aggregate root in Domain Driven Design?
You would normally arrange that all of the entities in the aggregate are loaded by the repository used to load the root. Your Root object must maintain its own consistency. ie remove children from its collection where required. The repository is responsible for persisting Root objects.