Domain Objects and Services

前端 未结 4 1211
鱼传尺愫
鱼传尺愫 2020-12-12 14:20

In this question someone replies \"You never let the domain object implementations call services by themselves!\". Is this statement a hard fast rule of DDD or does it depen

4条回答
  •  爱一瞬间的悲伤
    2020-12-12 14:37

    I think it's better not to call repositories or services from entities or value objects, but sometimes it's necessary, for example, if an entity has to return other entity which should be loaded from database but it cannot navigate to it using object graph. Then dependency inversion principle comes to help, which means that entities and value objects depend on interfaces of services and repositories and not on implementations.

提交回复
热议问题