.netdnsdomain-driven-designlightspeed

DDD Modeling question


I have these two structures in my domain: Exercise (with subjects, solution, difficulty ext.) and Subject which has a name and a father subject. Subject is defined by its attributes so in that sense it's a value object, However even if my current data store has nothing associated with a particular subject, that subject existence still might be relevant for the domain, so it can exist unrelated to anything- so is it an entity ?

Another question, say I want all existing subjects that have a particular name is it advisable to have a SubjectRepository (should only aggregate roots have associated repositories)?


Solution

  • I've seen a similar DDD case regarding an Address class.

    Domain-wise, the properties were the interesting part, not the id.

    However in order to re-use and edit them, they needed to be «entities» with no business id/key, only a primary id/key.

    In order to support smooth management in the GUI, Address was made an «aggregate roots» with a «repository».

    Your case sounds similar.