0

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.

remi bourgarel
  • 9,231
  • 4
  • 40
  • 73
  • Have you considered making a 'Grid' an aggregate root? Then have both Product & Offer reference the Ids of the grids? – David Masters Jul 10 '12 at 08:36
  • Isn't it just a workaround ? a grid doesn't exists by itself right ? I have considered it, but it scares me that in a long term I'll have only aggregate roots. – remi bourgarel Jul 10 '12 at 08:58
  • Well I don't know your full requirements, but designing small aggregates is not a work around. Read these **excellent** articles on the subject (the first one is most relevant): http://dddcommunity.org/library/vernon_2011 . 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 of it's own. – David Masters Jul 10 '12 at 09:02

1 Answers1

1

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

David Masters
  • 8,069
  • 2
  • 44
  • 75