33MVC, MVP, MVVM and angular difference

A, the MVC 
. 1, the Model
the Model corresponding application state and business function package, it can be appreciated that the field contains both data and behavior model (Domain Model). Model Controller accepts the request and complete the corresponding business processing, when the application state changes can give notice to the View.
2, View
View visualization interface presentation and capturing the end-user interaction. Model View can call directly to inquire about their status, and Model can be when their status changes, proactive notification View.
. 3, the Controller
Contoller is connected between the M and V, for controlling the application process. View forwards to capture user interaction directly Contoller, which performs the corresponding UI logic. If you need to involve invoking business functions, Contoller will direct calls to modify Model Model and state. Contoller also take the initiative to control or create a new View original View responds to user interaction.
Two, MVP
MVP suitable for event-driven application framework based.
1, MVP strictly prohibited direct interaction between the View and Model, necessary to be done by Presenter. Model's independence has been truly reflected, it is not only the visual elements of the presentation (View) has nothing to do, nothing to do with UI processing logic. MVP application using the user-driven rather than a Model-driven, so do not need to take the initiative to inform the Model view.
2, MVP mode V represents an interface, extract a UI interface and the abstract interface. Interface means that any implementation of the interface of the interface, are able to reuse existing Presenter and Model code. View details are isolated and the complexity of the model in the true sense, reducing the dependence on Presenter View of. UI benefits is to define processing logic Presenter becomes easy to test.
Three, MVVM
1, MVVM pattern, a ViewModel and View is a fully binding, modifications variations View all in, will be automatically updated to the ViewModel while ViewModel any changes will be automatically synchronized to display the View.
2, this automatic synchronization has been able to because the ViewModel properties have achieved such an interface observable, that is when the method attribute set, the event will be triggered simultaneously modify the properties of the bound UI auto-refresh .
3, in the MVP, V is the interface View, solve for coupling interface UI; and MVVM ViewModel is simply used directly and seamlessly UI, UI ViewModel can represent directly. But MVVM do is to rely on a specific platform and technology. This is the reason why the ViewModel do not need to implement the interface, because dependence on specific platforms and technologies that they can not replace the use of the platform UI using the MVVM pattern in nature.
Fourth, in the angular MVVM pattern is divided into four parts:
1, View: it focuses on the interface display and rendering, it is included in the angular view templates bunch of declarative Directive.
2, ViewModel: in the $ scope angular objects as the role of the ViewModel; ViewModel and View are completely binding, modifications variations View all in, will be automatically updated to the ViewModel, and any changes will be automatically synchronized to ViewModel View on display.
3, Model: The server returns data from Ajax or global configuration object; and the service is angular and processed encapsulation locus with a Model-related business logic, such business service, or can be a plurality Controller other areas of service reuse services.
4, Controller: The core element is not MVVM pattern, ViewModel responsible for initialization of an object, or a combination of a plurality of service will be acquired on the Model ViewModel business objects, such that when the boot loader application interface reaches a usable state .
Five, react in MVC is V, C and the like need to be introduced to act as a redux, M acquired by AJAX from the rear end; Angular MVVM is V and the VM, M acquired by AJAX from the rear end.

Guess you like

Origin www.cnblogs.com/gushixianqiancheng/p/10966401.html