samedi 17 février 2018

Should entities in a AggregateRoot also become an AggregateRoot

I'm trying to setup my domain models around the DDD principles. Right now I have the following class:

class Customer : AggregateRoot
{
    public string CustomerReference {get;set;}
    public string CustomerName {get;set;}
    public string List<Adult> Adults {get;set;}
    public string List<Child> Children {get;set;}
}

Creating a Customer is the essence of the application, so I made that class an AggregateRoot. Because a lot of times the end user will want to find a customer by its CustomerReference key.

But then again, sometimes the end user wants to search by the name of a Child, to find out the Customer info. Or even sometimes by the name of an Adult.

I'm not sure if that means that I should make the Child and Adult classes also an AggregateRoot? Or should I always start searching from the Customer AggregateRoot if I want to search by a Child or Adult name?

Aucun commentaire:

Enregistrer un commentaire