What are MVC, MVP, and MVVM respectively _ dynamic node Java school arrangement, mvcmvvm
I. MVC
The MVC pattern means that the software can be divided into three parts.
View: user interface.
Controller: business logic
Model: Data Storage
The communication methods between different parts are as follows.
1. View sends commands to the Controller
2. After the Controller completes the business logic, the Model is required to change the status.
3. The Model sends new data to the View. The user gets feedback.
All communications are unidirectional.
Ii. Interaction Mode
When receiving user instructions, MVC can be divided into two methods. One is to pass commands to the Controller through View.
The other is to directly receive commands through the controller.
Iii. Example: Backbone
Actual projects often adopt a more flexible approach, taking Backbone. js as an example.
1. You can send a command (DOM Event) to the View, and the View directly requires the Model to change the state.
2. You can also send commands directly to the Controller (the hashChange event is triggered when the URL is changed), and then the Controller sends the command to the View.
3. The Controller is very thin and only serves as a route. The View is very thick and the business logic is deployed in the View. Therefore, the Backbone simply cancels the Controller and retains only one Router ).
Iv. MVP
In MVP mode, the Controller is renamed as Presenter, and the communication direction is changed.
1. Communication between all parts is bidirectional.
2. View and Model are transmitted through Presenter.
3. The View is very thin and does not deploy any business logic. It is called the Passive View, that is, there is no initiative, and the Presenter is very thick. All the logic is deployed there.
V. MVVM
In MVVM mode, the Presenter is renamed as ViewModel, basically consistent with the MVP mode.
The only difference is that it uses data-binding: View changes, automatically reflected in ViewModel, and vice versa. Angular and ember both adopt this mode.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.