Aggregate root

Aggregate root (Aggregate Root) is a concept in DDD. It is a larger encapsulation that puts together a group of entities and value objects that have the same life cycle and are inseparable in business. Only the root entity can be external Exposing references is also a manifestation of cohesion.

The determination of the aggregation boundary must satisfy the fixed rule (Invariant), which refers to the consistency rule that must be maintained when the data changes. The specific rules are as follows.

  • The root entity has a global identity and is ultimately responsible for checking the rules.
  • The entities in the aggregate have local identities, and these identities are unique within Aggrate.
  • External objects cannot refer to any internal objects other than Entity.
  • Only the root Entity of Aggregate can be directly obtained through database query, and other objects must be discovered by traversing the association.
  • When any object within the Aggregate boundary is modified, all the fixed rules of the entire Aggregate must be satisfied.

Guess you like

Origin blog.csdn.net/gou553323/article/details/112970679