How should rules for Aggregate Roots be enforced?

前端 未结 5 2121
一向
一向 2021-02-06 02:21

While searching the web, I came across a list of rules from Eric Evans\' book that should be enforced for aggregates:

  1. The root Entity has global identity and is
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 03:16

    I don't think you should let the aggregate give your external code access to it's entities.

    You tell your aggregate what you want to happen and it deals with it.

    If we have an aggregate:Car. We don't care about petrol, and wheels, we just drive. We ask the car about things and it answers without giving references to the internals.

    We ask: Do we have petrol? Yes. Not: Give me the tank object so I can check if we have petrol.

提交回复
热议问题