MVC vs. MVP
来源:互联网 发布:c语言猜数字游戏代码 编辑:程序博客网 时间:2024/06/05 08:39
MVC vs. MVP
By now you should've heard of the Model-View-Controller design pattern. If you've read OOP with ActionScript by Branden and Sam then you're also somewhat familiar with the Model-View-Presenter design pattern. So what's the difference?
MVC came first. With the MVC pattern it's possible to separate your presentation information from your behind the scenes business logic. Think along the lines of XHTML/CSS and separating your content from your presentation. A brilliant concept that works quite well, but is not without it's faults.
In MVC, the model stores the data, the view is a representation of that data, and the controller allows the user to change the data. When the data is changed, all views are notified of the change and they can update themselves as necessary (think EventDispatcher).
MVP is a derivative of MVC, mostly aimed at addressing the "Application Model" portion of MVC and focusing around the observer implementation in the MVC triad. Instead of a Controller, we now have a Presenter, but the basic idea remains the same - the model stores the data, the view is a representation of that data (not necessarily graphical), and the presenter coordinates the application.
In MVP the Presenter gets some extra power. It's purpose is to interpret events and perform any sort of logic necessary to map them to the proper commands to manipulate the model in the intended fashion. Most of the code dealing with how the user interface works is coded into the Presenter, making it much like the "Application Model" in the MVC approach. The Presenter is then directly linked to the View so the two can function together "mo' betta".
Basically, in MVP there is no Application Model middle-man since the Presenter assumes this functionality. Additionally, the View in MVP is responsible for handling the UI events (like mouseDown, keyDown, etc), which used to be the Controllers job, and the Model becomes strictly a Domain Model.
Clear as mud, right?
If you're interested in this topic there's quite a bit of useful information out there, but you'll need to take the time to digest it. Check out the following links: (most of these are Smalltalk based, but should still be understandable)
- Model View Controller History
- Model-View-Controller framework
- Model View Controller
- (ootips) - Model-View-Contoller
- Model View Presenter
- Model-View-Presenter framework
- Pattern: Model-View-Presenter
- MVP: Model-View-Presenter (Java paper)
- Twisting the Triad
Above all, remember that MVC and MVP are just patterns. They're more or less a set of guidelines to follow when building applications. In the end, the developer can implement the application however they see fit.
- MVC vs. MVP
- MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM
- MVC VS. MVP VS. MVVM
- MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM
- 英文原文:MVC vs. MVP vs. MVVM
- MVC vs. MVP vs. MVVM on Android
- 安卓MVC vs MVP 框架
- 表现层系列:MVC vs. MVP vs. MVVM
- Web设计模式 之 - MVC vs. MVP vs. MVVM
- mvc mvp
- MVP mvc
- MVC+MVP
- vim快捷操作
- 关于窗口重画的初级问题
- java截屏代码
- 基础知识:MySQL数据类型及列类型
- 40种网站设计常用技巧
- MVC vs. MVP
- Tomcat虚拟目录设置
- C# Idioms:Enum还是Enum Class(枚举类)
- java 学习 01(2007/04/18)
- 谈谈Unicode编码,简要解释UCS、UTF、BMP、BOM等名词
- Asp.Net中使用水晶报表
- ServletContext与ServletConfig分析
- SQL基础:常用SQL语句详解
- 数据结构学习之二叉树小结