Am I allowed to have “incomplete” aggregates in DDD?

前端 未结 5 616
再見小時候
再見小時候 2021-02-05 10:04

DDD states that you should only ever access entities through their aggregate root. So say for instance that you have an aggregate root X which potentially has a lot of

5条回答
  •  走了就别回头了
    2021-02-05 10:46

    You are allowed since the code will compile anyway, but if you're going for a pure DDD design you should not have incomplete instances of objects.

    You should look into LazyLoading if you're afraid to load a huge object of which you will only use a small portion of its child entities.

    LazyLoading delays the loading of whatever you decide to lazy-load until the moment they are accessed. They make use of callbacks to call the loading method once the code calls for them.

提交回复
热议问题