This is the 25th day of my participation in Gwen Challenge
The MVC pattern
MVC mode is model-view-Controller, model-view-controller mode. The main purpose of the MVC concept is to separate the data model from the view and connect the two with the controller as a bridge and decouple them. MVC is actually a framework pattern rather than a design pattern, but it does not prevent us from understanding and getting familiar with this framework pattern. For developers, both design pattern and framework pattern are theoretical knowledge of development that need to be mastered.
Framework of hierarchical
View (V-view)
The view layer, as the top layer, can also be considered the interaction layer. For example, GUI graphical interface, user operation page, mobile client UI page, etc. Generally speaking, it is the most intuitive visual operation page that users can contact. They can do corresponding operations through the graphical interface and wait for the system to process the operation logic to show the final feedback effect. View layer V processes data through controller C, and then data processing is completed by model layer M, and rear view layer V reads the latest data information to update the page.
M-model
The model layer is also the core layer, which is mainly used to manage and preserve the data and information content in the system. When the view layer V updates the data of the model layer M through the control layer C, the control layer C will notify the model layer M to update the data, and the model layer M will notify the view layer V to refresh the page to display the latest data results in a visual form after the data is updated.
Controller (C-Controller)
The controller layer acts between the view layer and the model layer. When the view layer V updates data, controller C notifies the model layer M to deal with it. It mainly separates the view layer V from the model layer M.
The Android MVC
MVC scenarios are common in Android development. For Android, part of the page development is using the MVC pattern. The view layer in Android generally uses XML files to describe the layout of the page; The model layer is the data information obtained through local files or network requests in the application. The controller is assumed by the Android development Activity, which gets the model data as well as the page creation and page element fetching, and then binds the two. When data needs to be updated, the Activity processes the model and then updates the view.
conclusion
The MVC pattern is the decoupling of View and Model through Controller. Just like Android development, views exist independently and are generally implemented by XML layout descriptions. Ultimately, it is the Activity that combines the View and Model to perform other logical functions.
reference
- MVC pattern – Beginner tutorial
- Android Source Code Design Patterns