Han Mengfei sha Han Yafei [email protected] yue31313 Han_meng_fei_sha
The difference between MVC,MVP,MVVM
#MVC software can be divided into three parts
- View: User interface
- Controller: Business logic
- Model: Data saving
The means of communication between the sections are as follows:
- View Transfer command to Controller
- Controller needs model to change state after completion of business logic
- Model sends new data to view, user gets feedback
Tips: All communications are unidirectional.
MVC can be divided into two ways when #互动模式 accept user directives. One is passed to the controller through the view acceptance instruction.
The other is to accept the instructions directly through the controller.
#MVP
The MVP mode renamed Controller to presenter and changed the direction of communication.
- The communication between the parts is bidirectional
- View and model do not contact, are passed through presenter
- The view is very thin and does not deploy any business logic, called the "Passive View" (Passive view), without any initiative, and presenter is very thick, where all the logic is deployed.
#MVVM
The MVVM pattern renamed presenter to ViewModel, which is basically exactly the same as the MVP model.
The only difference is that it uses two-way binding (data-binding): The change of view is automatically reflected in ViewModel, and vice versa.
MVC,MVP and MVVM in Android