Reputation: 608
I have an Appointment
Aggregate Root, for the aggregate to be valid in terms of the business it must have a reference to a number of other aggregates which increase the size dramatically; Client
, Employee
, Service
, Start/End Date and Time.
The Appointment
is rehydrated from a web service and it seems it would be impractical to fetch all of this information every time I want to get a list of appointments or even just a single appointment.
I must be doing it wrong, the Client
, Employee
, and Service
are themselves aggregate roots with their own repository like interface, as they can all exist by themselves.
Would it be an idea to just keep the IIdentity
of the aggregates in the Appointment
aggregate root and load them separately when needed (eg. ClientId
, EmployeeId
, ServiceId
)?
I find this to be a very common problem with my first foray into DDD.
Thanks for all your help
Upvotes: 0
Views: 640
Reputation: 28737
A rule of aggregates is that anything that belongs to the aggregate cannot be accessed from outside the aggregate root. By having a Client
, Employee
and Service
part of your aggregate, you are breaking this rule.
It's better to just have an Id to those entities and break up your aggregates so that they don't interfere with eachother.
Upvotes: 2