RE: Re: Can an Entity be Shared across many Aggregates?

<[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <[email protected]>
Thanks everyone.  This makes sense.  It seems the Account entity needs to be modeled as an aggregate with identity links.  

 

 Though now I am confused about the Tire and Wheel example.  I don't know how you would maintain invariants based on object instance across aggregates.  This seems messy and problematic.

 

---In [email protected], <david_hounslow@...> wrote:

 I think the example you give of tire and wheel with truck and Car is a 
 different situation to the one you have with account.
 
 In the Truck and Car example it >might< be acceptable to re-use the tire 
 and wheel classes as these will be referring to different instances i.e. 
 A tire an wheel are specific instances tied to either a tire or a truck. 
 But note what you are not doing here is referring to a sub part of 
 another aggregate root, i.e. a truck is not referring to a cars tire (or 
 one car is not referring to another's tire for that matter).
 
 But in the account example it sounds as if you are wanting to refer to 
 the same account instance in different places. In this case this needs 
 to be an aggregate root in its own right.
 
 Whether you should you re-use value objects that represent the account 
 or not is a different issue, but I would caution against it generally 
 you would only want to refer to the account id in another aggregate, and 
 a shipping aggregate root might have a different view of the attributes 
 related to an account to a payment processor for example.
 
 Dave.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.