Re: Can an Entity be Shared across many Aggregates?
Greg Young <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <CAC9RQtjwwY=0nKPkYDBZr_8hW2z9Y5Uj=HMqxB9Occ37W2VM+Q@mail.gmail.com> |
No. The reason why is the aggregate maintains invariants, how would one aggregate notify the other on change of an entity... If it didn't then you could possibly have an aggregate in an invalid state. Yes likely you want it as it's own aggregate with soft links. Btw there is no problem accessing the id of an entity from outside, the problem is the same entity being in two aggregates Greg On Sunday, November 10, 2013, wrote: > > > Can an entity be shared across many aggregates? In the Blue Book (Evans), > in chap 6 on aggregates there is an example of entities Tire and Wheel > being used in the aggregate root Car. If this example was extended to have > two aggregates, Car and Truck would it be acceptable to use Tire and Wheel > again with Truck? > > In the domain I'm currently modeling, there is an entity called Account. > It's a very specific domain type of account. Right now I have it modeled > as an entity in an aggregate root that manages it's life-cycle, but it's > used heavily in other aggregate roots as a reference. It would suggest > that what I really need is to make Account an aggregate root in it's own > right so I can reference it's ID in other aggregates. Because from my > understanding it's not acceptable to reference an entity's Id or the entity > itself outside it's owning aggregate. What am I missing? > > Apologizes for the two part question. > > -- Le doute n'est pas une condition agréable, mais la certitude est absurde.