In Domain Driven Design (DDD), an Entity always has its own unique identity.
In my reading on DDD I have seen statements and examples that seem to mix the concepts of "unique identity" between Entities and Aggregate Roots. Depending on the example, they can imply that:
- I only need one of the interfaces below.
or
- I need both.
I would like to know which approach is "correct" as far as "Eric Evans type DDD" is concerned.
For example, let's say your Entities implement this interface and return a GUID when this method is called:
public interface IEntity
{
object IdThatIsUniqueForThisEntityObject { get; }
}
Do you need the one below too or not?
public interface IAggregateRoot
{
object IdThatIsUniqueForThisAggregateRootObject { get; }
}
Does the Aggregate Root need to implement an interface like the one above so that it can represent its own unique ID (IdThatIsUniqueForThisAggregateRootObject) that is separate and different from its root Entity's ID (IdThatIsUniqueForThisEntityObject)?
Or should the Aggregate Root just use the root Entity's (IdThatIsUniqueForThisEntityObject) to represent the Unique ID of the Aggregate Root?