How to model an aggregate that spans multiple contexts?

141 views
Skip to first unread message

pstanl...@gmail.com

unread,
Jun 8, 2017, 8:06:07 AM6/8/17
to DDD/CQRS

Let's say we have an entity "Product" with multiple attributes, e.g. Name, Price, Customers. And we have two departments Department I and II which both deal with the product. But: Dep I is interested only in Name and Price, whereas Dep II is interested in Name and Customers.
Now let's regard "Product" as an aggregate. This is used by 2 bounded contexts, e.g. Department I and Department II. The question is how to model this.
One option would to have two aggregates for both contexts where Name is redundant.
The other option would be to use a shared kernel - interesting here is how to model then a "split" aggregate. My idea is in the attached sketch. I.e. the shared kernel contains the super class and the BCs derive from it. Does this makes sense from a DDD perspective?


 

Danil Suits

unread,
Jun 8, 2017, 9:31:50 AM6/8/17
to DDD/CQRS
What I see in your sketch is not one aggregate with a shared kernel but two aggregates with ambiguous authority over Product.Name.

Therefore, I would argue that no, it doesn't make sense. 

Instead, take each shared element, identify that context that has authority over the data, and move the element to the appropriate aggregate within that context.


Reply all
Reply to author
Forward
0 new messages