【网摘】Model View Presenter (MVP) Pattern
2009-11-29 22:48
295 查看
Source: http://blog.vuscode.com/malovicn/archive/2006/10/10/Model-View-Presenter-_2800_MVP_2900_-pattern.aspx
What is MVP?
View is responsible for visual representation of the form and it contains a presenter in private field. View is implementing interface whose members are approximated and technology striped UI elements of the view. When some event occurs on view is just forwarding it to presenter and it is presenter responsibility to handle the event. Presenter is manipulating view by talking to interface representation of the view. Presenter should never reference directly view members (UI controls). Presenter for his logic operations is using Model which can be persisted state or representation of the object which provides necessary functionality
MVP 与 MVC 最大的区别就是 View跟Model不直接打交道的。 从上面的这张图可以看出,Presenter充当一个“中间人”的角色。
从TDD的角度来说,MVP的好处是便于测试,因为UI层的代码除了控件,几乎没有其他东西了,逻辑处理都由这个P来承担。因此,不需要第三方专门用于UII(Web Page)的测试工具。
MVP pattern is a type of UI design pattern which enables decoupling of the UI logic without UI representation and by that enables treating code base without consideration on presentation technology used.
All the logic is inside the presenter and the presenter is talking to view only through the interface, so any mock object could be used for testing as long it implements the view interface
What is MVP?
View is responsible for visual representation of the form and it contains a presenter in private field. View is implementing interface whose members are approximated and technology striped UI elements of the view. When some event occurs on view is just forwarding it to presenter and it is presenter responsibility to handle the event. Presenter is manipulating view by talking to interface representation of the view. Presenter should never reference directly view members (UI controls). Presenter for his logic operations is using Model which can be persisted state or representation of the object which provides necessary functionality
MVP 与 MVC 最大的区别就是 View跟Model不直接打交道的。 从上面的这张图可以看出,Presenter充当一个“中间人”的角色。
从TDD的角度来说,MVP的好处是便于测试,因为UI层的代码除了控件,几乎没有其他东西了,逻辑处理都由这个P来承担。因此,不需要第三方专门用于UII(Web Page)的测试工具。
MVP pattern is a type of UI design pattern which enables decoupling of the UI logic without UI representation and by that enables treating code base without consideration on presentation technology used.
All the logic is inside the presenter and the presenter is talking to view only through the interface, so any mock object could be used for testing as long it implements the view interface
Conclusion
MVP is very powerful UI design pattern which has multiple benefits for developing all kinds of user interfaces. That is the reason why CAB (Composite Application Block) is using it as a one of basic UI building principles相关文章推荐
- MVP(model,view Presenter) Pattern(模式) 学习
- Model View Presenter (MVP) design pattern and data binding
- Model-View-Presenter: Variations On The Basic Pattern (Introduction To CAB/SCSF Part 24)
- NBearV3教程——MVP(Model/View/Presenter)篇
- Model View Presenter (MVP)
- 探索MVP(Model-View-Presenter)设计模式在SharePoint平台下的实现
- NBearV3教程——MVP(Model/View/Presenter)篇
- MVP 模式(Model-View-Presenter)可以说是 MVC 模式(Model-View-Controller)在 Android 开发上的一种变种、进化模式。
- MVP (Model View Presenter ) 简介
- 在ASP.NET中实现Model-View-Presenter(MVP)
- MODEL-View-Presenter(MVP)模式在FLEX下的开发实例
- 在ASP.NET中实现Model-View-Presenter(MVP)
- Asp.net MVP & MVC 之 ASP.NET Model-View-Presenter
- 设计模式:Model View Presenter(MVP)
- 探索MVP(Model-View-Presenter)设计模式在SharePoint平台下的实现
- 介绍MVP Model-View-Presenter在Android中的应用
- 在ASP.NET中实现Model-View-Presenter(MVP)
- 使用ASP.NET实现Model View Presenter(MVP)
- ASP.NET MVP( Model View Presenter )微软官方介绍
- 在ASP.NET中实现Model-View-Presenter(MVP) (转)