How should rules for Aggregate Roots be enforced?

前端 未结 5 2133
一向
一向 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:15

    My favourite way of enforcing DDD patterns and practices is constantly educating people about their value. There are however moments when I with I had a more rigorous tool.

    I haven't done this myself yet, but is seems to me that FluentNHibernate could be a good tool for enforcing aggregate properties.

    Your example could be implemented by marking all aggregate roots with 'IAggregateRoot' marker interface and non-root entities with 'IEntity' marker interface. Then, your custom FNH convention would check for entities marked as IEntity referencing entities IEntity and when found, would signal an error (throw an exception for example).

    Does it make any sense?

提交回复
热议问题