domain-driven-design

How do I access an entity behind my aggregate root?


I am into my first week of DDD and have a couple of entities with aggregate roots defined.

I read that no external entity outside of an aggregate can reference an entity in an aggregate, so the external entity has to reference the aggregate root.

Well, unless I have modelled my solution incorrectly I need a reference to an entity behind the aggregate root. How do I handle this situation or do I have to remodel my domain to avoid this situation?

JD


Solution

  • You probably could refine your model. If an external reference to an entity inside your aggregate is required, then that is a strong indicator that the internal entity might be an aggregate root itself.

    This of course is general advice since I don't know anything about your specific model.

    For great advice concerning aggregate design, have a look at this paper by Vaughn Vernon. In Part I, "Modeling of an Aggregate", he specifically addresses aggregate granularity which I found very enlightening.