Deepen the conceptual understanding of MVC, MVP and MVVM



  • MVC
    • Misunderstanding and reason of MVC
  • MVP
  • MVVM


MVC – Wikipedia, free encyclopedia

MVC is a software architecture mode of software engineering. It is not a specific technology, but a concept of code stratification, which mainly embodies the principle of separation of responsibilities.

M-model model

V-view view

C-controller controller

Misunderstanding and reason of MVC

Misunderstanding: page view = view, entity and dto = model

Reason: when I first started my career as a programmer, I came into contact with web form project. However, web form didn’t have a good plan and definition for the responsibilities of controller and view, so I roughly considered page view as view layer. The view page is scattered under each controller. Although we try our best to name the folder clearly, because the model is not well implemented, dto flies around, and data access code can be seen everywhere in the controller. Code piles up in some controller files, and various logics are all in the controller layer.

Try to optimize: put view under a folder, separate entity and dto independent class library, and separate data access layer, business logic layer and common method layer

The project structure is probably

  • Demo.Web
    • Views
    • Controllers
  • Demo.Entity
  • Demo.Dto
  • Demo.DataAccess
  • Demo.Business
  • Demo.Common

Less perfect result: after optimization, the code structure is much clearer than before. The controller puts data binding code and XSS verification and SQL injection verification for parameters. However, new problems arise, such as changes in database fields or business adjustments. Changes in the model layer involve entities, dto, dataaccess, and business. The comparison between web form and MVC is not made here.


MVP is an extension of MVC mode, not a substitute.


PresenterIt contains event processing of components, which is responsible for retrieving data obtained by model and communicating with view through format conversion.

From Model View Presenter Wikipedia, free encyclopedia

In my opinion, the presenter layer should be included in the business layer, because part of the responsibilities of the business layer in the planning are exactly the same as the above references. Because there is no more specific planning of presenter, the business layer and controller layer in later projects are mixed with the responsibility code that should be undertaken by presenter layer, which reduces the maintainability of the project.


MVVM helps to align GUI development with business or back-end logic(data model)Development is separated by markup language or GUI code. MVVMView modelIs a value converter, [1], which means that the view model is responsible for exposing (transforming) data objects from the model for easy management and rendering of objects. In this respect, the view model does more than the view, and handles the display logic of most views. [1] The view model can implement the mediator pattern and organize the access to the back-end logic of the use case set supported by the view.

From MVVM – Wikipedia, free encyclopedia

ViewModel, as a mediator, shields the data binding process code and GUI code. With the help of XML markup language, complex GUI presentation can be easily completed. The power of WPF is needless to say.

Here we recommend two open source projects based on MVVM development mode

  • riganti/dotvvm: Open source MVVM framework for Web Apps
  • Dotnetcore / WTM: WTM framework is a powerful tool for the development of small and medium-sized background management system. Based on dotnetcore, the project is created by 0 code, and the business module is generated by 0 code. The framework strictly follows the development mode of MVVM and gets the essence of MVVM. For the novice, you can build projects quickly; for the expert, you can give those tedious and repetitive work to the framework generation, and concentrate on overcoming the needs and difficulties. After dozens of real project tests, the framework can greatly improve development efficiency and reduce development costs.

Recommended Today

PHP realizes UnionPay business H5 payment

UnionPay business H5 payment interface document: document address 1: H5 payment interface address: 1: Alipay payment Test address: Official address: 2: UnionPay payment Test address: Official address: 2: Basic parameters required by the interface The interface uses get parameters. After the interface parameters are directly put into the interface address, the […]