Can one Aggregate Root have multiple subtypes

by designermonkey   Last Updated December 16, 2017 23:05 PM

I have a concept that I am struggling to design in a DDD CQRS manner, and I hope to find some insight.

In the old days (before I knew DDD) I would have used simple inheritance, and that's how my mind is wrapping around the following...

  • I have a domain concept: Property
  • There is a SingleValueProperty which has a PropertyType and a Value
  • There is an AttributedProperty which has a collection of Attributes

The latter two are basically the same base concept as they share 8 class attributes, and would use the same Commands and Events to be managed in the domain. I am stuck at how to furnish them in the DDD Aggregate Root concept as it feels weird to have the Repository return different types of object.

On the other hand, I also feel that it's ok and still follows the SOLID principles, as this is what inheritance is for right?

Anyone got any hints on how to model this dilemma?


I want to add more context as it may sway the consideration.

A Property is created with only it's main 8 attributes. After that the other aspects like addition of Attributes or choice of PropertyType are added to the Property. Does this mean 3 separate aggregate roots?

Related Questions

CQRS - Passing aggregate root as argument

Updated February 25, 2017 23:05 PM