Search code examples
domain-driven-designddd-repositories

DDD - Domain Model Problem


I have i discussion with a partner we have this scenario:

**Publishers root entity 
Advertiser root entity**

Each of those entities share common info : Email, BillingAddress, NormalAddress, sex, SSN, etc.

I have decide: Person Entity with a Value object Address and rest of properties. This way if i want to access a specific info about a Person (email, sex, dateofbird) i dont have to go through publisher or advertiser root entities to get it (treat Person as an aggregate root).

Sample: **Person.BillingAddress.Address1 :
        Person.BillingAddress.Address2 :
        Person.BillingAddress.POBOX :
        Person.Email :
        Person.Sex**

My teammate propose to to do it using abstract class, advertiser and publisher inherits from Person abstract class in order to have all common properties.

What is the best way to do it?. If you have one please guide us.

Thanks, Pedro de la Cruz


Solution

  • I think that you are right. Inheritance just make sense when the behaviour is common (some thing is a kind of other thing), then Person isnt a kind of OTHER THING just because the properties are similars. It isnt code reuse.