Can a root entity hold reference to anything outside the aggregate boundary?

Can a root entity hold reference to anything outside the aggregate boundary?

Nothing outside the Aggregate boundary can hold a reference to anything inside, except to the root Entity. The root Entity can hand references to the internal Entities to other objects, but they can only use them transiently (within a single method or block).

How are the roots of an aggregate obtained?

Only Aggregate Roots can be obtained directly with database queries. Everything else must be done through traversal. Objects within the Aggregate can hold references to other Aggregate roots. When a change to any object within the Aggregate boundary is committed, all invariants of the whole Aggregate must be satisfied.

Can a delete operation remove references to other aggregates?

Objects within the Aggregate can hold references to other Aggregate roots. A delete operation must remove everything within the Aggregate boundary all at once. When a change to any object within the Aggregate boundary is committed, all invariants of the whole Aggregate must be satisfied.

What are entities, value objects, aggregates and roots?

Entities and Value Objects are but a slice in the DDD world, but a core concept which many other ideas are built upon. We were unable to load Disqus Recommendations.

Can a root entity hand reference to an internal entity?

The root Entity can hand references to the internal Entities to other objects, but they can only use them transiently (within a single method or block). Only Aggregate Roots can be obtained directly with database queries. Everything else must be done through traversal.

When does an entity have a reference object?

If the answer is “yes”, and I care about an identity, then the class is indeed an entity. I model entities with reference objects (classes), and I give them a surrogate identity (i.e., probably a GUID). Additionally, my model must include what it means to have the same identity.

How are aggregates and entities used in Domain Driven Design?

A Purchase Order would probably need to have at least one Line Item to be valid. Here is a case of two or more objects that seem to belong together most of the time in terms of how you need to work with them. So treat PO as an aggregate of the PO entiity and the Line Item value objects. And make the PO entity the root of the aggregate.

When do invariants need to be enforced in an aggregate?

Invariants need to be enforced not only in an Entity, but in all the Entities that are referenced as well. That gets tough to maintain, and quick! Aggregates draw a boundary around one or more Entities. An Aggregate enforces invariants for all its Entities for any operation it supports.