Talking about the difference between MVC, MVP, and MVVM architectural patterns

MVC, MVP, MVVM these modes are proposed to solve practical problems in the development process, and are widely used as several mainstream architectural modes at present.

一、MVC(Model-View-Controller)

MVC is a relatively intuitive architectural pattern, user operation -> View (responsible for receiving user input operations) -> Controller (business logic processing) -> Model (data persistence) -> View (feedback results to View).

MVC is widely used, such as SSH framework (Struts/Spring/Hibernate) in JavaEE, Struts (View, STL)-Spring (Controller, Ioc, Spring MVC)-Hibernate (Model, ORM) and ASP in ASP.NET. NET MVC framework, xxx.cshtml-xxxcontroller-xxxmodel. (In fact, the back-end development process is vcmcv, v and m have nothing to do, the following figure only represents the classic mvc model)
write picture description here
2. MVP (Model-View-Presenter)

MVP is to replace the Controller in MVC with Presenter. The purpose is to completely cut off the connection between View and Model. Presenter acts as a bridge to completely isolate the communication between View and Model.

The ASP.NET webform and winform-based event-driven development technology that .NET programmers are familiar with is the MVP pattern used. The page composed of controls acts as the View, the entity database operation acts as the Model, and the control data binding operation between the View and the Model belongs to the Presenter. The handling of control events can be implemented through a custom IView interface, and both View and IView will be responsible for the Presenter.
write picture description here

三、MVVM(Model-View-ViewModel)

If MVP is a further improvement of MVC, then MVVM is a complete change in thinking. It takes the idea of ​​"two-way binding of data model data" as the core, so there is no connection between the View and the Model, and the interaction is performed through the ViewModel, and the interaction between the Model and the ViewModel is two-way, so the data of the view will change. At the same time, modify the data source, and the changes in the data source data will be reflected on the View immediately.

Typical applications in this regard include .NET WPF, js framework Knockout, AngularJS, VUE, React, etc.
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326016320&siteId=291194637