How to implement Unit of work in MVC: Responsibility

前端 未结 4 1605
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 09:08

Who has the responsability


Who has the responsibility to start and finish the Unit of work in a MVC architecture?

4条回答
  •  失恋的感觉
    2021-01-12 09:48

    As zihotki said you would be violating the SRP if you give this responsibility to the controller. This is a data manipulation oriented pattern, and as such should not be a concern for the controller ... that would make it two violations: one for the SRP and anothrt for the SoC principle.

    As for who has the responsibility, that's something to be defined by your architecture. The StartRequest/EndRequest suggestion seems solid enough.

提交回复
热议问题