Controller belongs to the Presentation layer?

后端 未结 3 1813
鱼传尺愫
鱼传尺愫 2020-12-24 14:43

I heard that controller belongs to the presentation layer. How is it possible?

I thought that :

  • view is for presentation
  • model is for business
3条回答
  •  别那么骄傲
    2020-12-24 15:30

    It largely depends on what flavor of MVC you're using, and what environment you're using it in.

    For example, ASP.NET MVC is entirely a UI pattern, so all three parts are part of presentation.

    However, in most implementations of MVC, the Controller interacts with the user, and thus is part of the UI layer. It may handle button presses, and keyboard input... but in many cases, the controller is also responsible for connecting the Model and the View together.

    The one universal truth is that you should NOT be doing business logic in the controller if you cannot help it. Where the business logic exists depends on many factors. It might be part of the model in some implementations, or it may be it's own separate layer outside of MVC

提交回复
热议问题