Brief mvc, mvp and the mvvm

MVC is one of the most classic pattern of development, when the university teacher is teaching this.

MVC(Model,View,Control)

MVC has two obvious questions:

1.m v layer and the layer directly contact, the two layers resulting in high coupling

2. Because all logic is written in c layer, resulting in a bloated c layer special

In order to solve these two problems, MVC model variants appeared MVP and MVVM.


MVP(Model,View,Presenter)

MVC architecture variant manner, instead of using the Presenter Control, but not directly change the flow of data between, View and Model interaction, but all performed by Presenter. Presenter while holding View and Model, View and Model while also each contain references to the Presenter. When the view changing the View, the data needs to be updated to notify by Presenter Model for data updates, the update data when the same occurs, the amount by which the self-contained to notify Presenter View to update reference. Such Presenter can be used as a bridge to link the two, and the traditional Activity only need to draw the UI, it can be presented.

  • Pros: The advantage is that you can get the entire software layered clear, reduce the degree of coupling, but also from both the Activity View Control is a situation freed, only to a single charge of UI, the task of reducing the Activity

  • Disadvantages: The disadvantage is the need to coordinate adding Presenter and Model View as a bridge, but also lead to Presenter become very bloated, while maintaining relatively inconvenient. And for each Activity, we require a corresponding substantially to the corresponding Presenter. To alleviate this bloated, MVVM appeared.


MVVM(Model,View,ViewModel)

MVVM is actually an improvement MVP, he will replace Presenter became ViewModel, and to interact via two-way data view and data binding. That only need to view data and binding once, then later when it will automatically refresh on the UI when data changes without the need to manually refresh ourselves. In MVVM, he will be simplified as much as possible to the data stream, to make it more concise.

This architecture is currently the main use databing framework, the framework for this next chapter explains.

Published 24 original articles · won praise 5 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_26923265/article/details/82622652