Is the Controller in MVC considered an application service for DDD?

后端 未结 4 1449
春和景丽
春和景丽 2020-12-14 02:10

I am applying DDD for the M part of my MVC and after some research (studying up!), I have come to the realization that I need my controller to be interacting with domain ser

4条回答
  •  庸人自扰
    2020-12-14 02:29

    In DDD Reference controllers are not mentioned at all. So I think from DDD POV the answer is undefined. So I would consider more practical question: "Do we need to separate Controllers and Application Service"?

    Pros:

    • Separating input processing from use case implementation.

    Cons:

    • Extra layer of indirection that complicates understanding of simpler cases. (It is also annoying to implement some trivial thing by pulling data though many layers without anything actually being done).

    So I would choose separation of controller and application service if input processing obfuscates use case logic. I would choose to keep use case logic in controller if both are simple enough so that you can easily see in code use cases separately from input processing.

提交回复
热议问题