Bypassing Aggregate Root

前端 未结 2 1009
广开言路
广开言路 2021-01-15 13:34

Is it okay to get a read-only collection from an aggregate without going through the root to get it? My model does some of this right now and I was wondering if that\'s an a

相关标签:
2条回答
  • 2021-01-15 13:45

    Actually Eric has changed his mind about the strictness of the Aggregate Root Rules.
    He recently said something along the lines of

    "Chill out dude. Try to stop yourself from breaking the rules man. But, hey, don't beat yourself up over it. DDD rocks dude, but break the Agg rules if ya really need to. Yeah, peace."

    See: "Eric Evans: What I've learned about DDD since the book" http://ffffdcommunity.org/library/evans_2009_1

    0 讨论(0)
  • 2021-01-15 14:04

    Evans says "The root is the only member of the AGGREGATE that outside objects are allowed to hold references to..." (p. 127)

    My understanding is that the aggregate should appear as a unit to outside objects. Also, the Law of Demeter would seem to apply. Bottom line, I don't think it's acceptable.

    0 讨论(0)
提交回复
热议问题