How to reference a leaf from a different root?
-
20-06-2021 - |
문제
I have this design :
A product has many pricing grids, a grid has many pricing periods
Product
Id
Name
Grids[]
Name
Periods[]
Price
Start
End
Now I have special offers, when a seller create an offer (for instance -10%) he can choose to apply it to a Product or even to a Grid (for instance he doesn't want to apply the offer to the grid "www.apartnerwebsite.com" but he prefers to apply it to the grid "my website").
Offer
OfferId
OfferName
ProductIds[]
GridIds[] //??
But I can't do this because there is no grid ids and I can't reference a Leaf from a root aggregate.
해결책
It seems to me that Grid is a contender to be its own aggregate root. If a Grid forms part of an Offer, as well as a Product then it would make sense to me to make it an aggregate root. Products & Offers would references their Grid's by ID.
As I mentioned in my comment, you shouldn't fear having a large number of small aggregates. This is actually a positive thing, as Vernon documents in his excellent article: http://dddcommunity.org/library/vernon_2011