当前位置:网站首页>The difference between MVC and MVP and MVVM
The difference between MVC and MVP and MVVM
2022-07-27 16:43:00 【Young people in Baima town】

MVC,MVP,MVVM The difference between design architecture , I believe you all know these concepts .
First , Be clear , The purpose of architecture is to improve development efficiency , Reduce maintenance costs .
Using object-oriented design principles , Divide the responsibilities of each module reasonably , In order to let others better understand the architectural design idea , Then give each module a general term explanation , To better clarify data binding , Here is a brief explanation of several common architectures ( With Android For example ).
MVC:- The model layer (
Model), Responsible for processing data logic , Generally, it includes database 、 Local data 、 Internet accessBeanOther components . - View layer (
View), Responsible for handling view display , Generally byXMLThe layout assumes this responsibility , Basic components and customizationViewAs a supplementary element of the view layer . - Control layer (
Control), Responsible for handling business logic , Generally byActivity、FragmentAssume this responsibility .
- The model layer (
MVP:- The model layer (
Model), Responsible for processing data logic , Generally, it includes database 、 Local data 、 Internet accessBeanOther components . - View layer (
View), Responsible for handling view display , Generally byXMLThe layout assumes this responsibility , Basic components and customizationViewAs a supplementary element of the view layer ,Activity、FragmentAct as an adhesive between the view layer and the control layer . - Logic layer (
Presenter), Responsible for handling business logic , From the original MVC Extracted from the control layerPresenterAct as the control layer (Presenter).
- The model layer (
MVVM:- The model layer (
Model), Responsible for processing data logic , Generally, it includes database 、 Local data 、 Internet accessBean、( Here I extract the view data separatelyViewDataThe concept also belongs to Model layer ) Other components . - View layer (
View), Responsible for handling view display , Generally byXMLThe layout assumes this responsibility , Basic components and customizationViewAs a supplementary element of the view layer ,Activity、FragmentIt is mainly responsible for the triggering of view layer binding events , Skilled words can also be directly inXMLBinding trigger event in . - Logic layer (
ViewModel), Connect through data bindingViewandModel( Here fromViewDataActing as a view model is bound to the view ) Realize the decoupling of view layer and model layer , Pass after the event is triggeredViewModelProcess business logic , And modify the view data in a data-driven way , And achieve the function of indirectly modifying the view . Be careful :ViewModelYou must not hold a reference to the view layer , Also cannot hold Context References to ! Or else MVP!
- The model layer (
MVC,MVP,MVVM The difference between design architecture , I believe you all know these concepts .
First , Be clear , The purpose of architecture is to improve development efficiency , Reduce maintenance costs .
Using object-oriented design principles , Divide the responsibilities of each module reasonably , In order to let others better understand the architectural design idea , Then give each module a general term explanation , To better clarify data binding , Here is a brief explanation of several common architectures ( With Android For example ).
MVC:- The model layer (
Model), Responsible for processing data logic , Generally, it includes database 、 Local data 、 Internet accessBeanOther components . - View layer (
View), Responsible for handling view display , Generally byXMLThe layout assumes this responsibility , Basic components and customizationViewAs a supplementary element of the view layer . - Control layer (
Control), Responsible for handling business logic , Generally byActivity、FragmentAssume this responsibility .
- The model layer (
MVP:- The model layer (
Model), Responsible for processing data logic , Generally, it includes database 、 Local data 、 Internet accessBeanOther components . - View layer (
View), Responsible for handling view display , Generally byXMLThe layout assumes this responsibility , Basic components and customizationViewAs a supplementary element of the view layer ,Activity、FragmentAct as an adhesive between the view layer and the control layer . - ??(
Presenter), Responsible for handling business logic , From the original MVC Extracted from the control layerPresenterAct as the control layer (Presenter).
- The model layer (
MVVM:- The model layer (
Model), Responsible for processing data logic , Generally, it includes database 、 Local data 、 Internet accessBean、( Here I extract the view data separatelyViewDataThe concept also belongs to Model layer ) Other components . - View layer (
View), Responsible for handling view display , Generally byXMLThe layout assumes this responsibility , Basic components and customizationViewAs a supplementary element of the view layer ,Activity、FragmentIt is mainly responsible for the triggering of view layer binding events , Skilled words can also be directly inXMLBinding trigger event in . - ??(
ViewModel), Connect through data bindingViewandModel( Here fromViewDataActing as a view model is bound to the view ) Realize the decoupling of view layer and model layer , Pass after the event is triggeredViewModelProcess business logic , And modify the view data in a data-driven way , And achieve the function of indirectly modifying the view . Be careful :ViewModelYou must not hold a reference to the view layer , Also cannot hold Context References to ! Or else MVP!
- The model layer (
边栏推荐
- Implementation of filler creator material editing tool
- OpenCV(三)——图像分割
- gpt-2 文本生成
- [paper reading] a CNN transformer hybrid approach for cropclassification using multitemporalmultisensor images
- C language output string in reverse order
- Leetcode25 question: turn the linked list in a group of K -- detailed explanation of the difficult questions of the linked list
- The 21st - -- the 30th time
- 除了「加机器」,其实你的微服务还能这样优化
- codis集群部署
- CCF-201312-1
猜你喜欢

2021 national vocational college skills competition (secondary vocational group) network security competition questions (9) ideas

training on multiple GPUs pytorch

Apache

减小PDF文档大小(转载)

The whereor method of TP5 has many conditions

The 21st - -- the 30th time

【论文阅读】A CNN-transformer hybrid approach for decoding visual neuralactivity into text

MySQL high version report SQL_ mode=only_ full_ group_ By exception

Opencv (II) -- basic image processing

Scala for loop (loop guard, loop step size, loop nesting, introducing variables, loop return value, loop interrupt breaks)
随机推荐
Log management
2021-06-02
Scala branch control (single branch, double branch, multi branch), return value of branch judgment
string数字类型转换为千分位
Addition of large numbers
补充—整数规划例题
爬取常见英文名
google chrome revercecaptcha广告屏蔽
Duplicate numbers in array
重新配置cubemx后,生成的代码用IAR打开不成功
training on multiple GPUs pytorch
SolidWorks simulation curve attribute setting
TP5 rewrite paging
KMEANS 实现
201403-1
2021-06-02
ROS - error in running.Py file in the project
最大子段和 Go 四种的四种求解
Implementation of filler creator material editing tool
Const summary