Domain Driven Design and IoC/Dependency Injection

前端 未结 5 1859
借酒劲吻你
借酒劲吻你 2021-02-02 00:43

I\'m trying to apply now what I learned about DDD and I\'m a little bit confused about the flow of dependencies in the Domain model.

My questions are:

  1. Shou
5条回答
  •  半阙折子戏
    2021-02-02 01:24

    I'll answer this with the precondition that I don't think there is a right answer, just different approaches.

    Thinking in terms of domain objects I would say the first approach is DDD. You are dealing purely with domain objects.

    I do think however there are uses for a service object that exposes this as part of an API/Service layer. In this case you would wrap your code from #1 within your service #2. This allows you to avoid exposing your domain objects to external consumers - and you can keep the external interface/API unaltered while updating your domain model.

    This however is just one opinion.

提交回复
热议问题