惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
WordPress大学
WordPress大学
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
L
LangChain Blog
雷峰网
雷峰网
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
NISL@THU
NISL@THU
Scott Helme
Scott Helme
量子位
S
Security Affairs
T
Threat Research - Cisco Blogs
博客园_首页
云风的 BLOG
云风的 BLOG
D
Docker
AWS News Blog
AWS News Blog
腾讯CDC
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
U
Unit 42
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
T
The Exploit Database - CXSecurity.com
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Last Watchdog
The Last Watchdog
C
Cybersecurity and Infrastructure Security Agency CISA
IT之家
IT之家
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
F
Full Disclosure
L
Lohrmann on Cybersecurity
The Hacker News
The Hacker News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
S
Security @ Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
I
InfoQ

博客园 - 风满袖

如何进行有效的沟通(二) 如何进行有效的沟通(一) SOA——概念 (转)Locale 详解 A XMLBean Tip 在Weblogic8.1.4服务器上安装Alphablox8.4 BI相关的术语 开源BI系统简述 如何收集项目需求 Prefactoring——Guidelines Prefactoring——Introduction Create C++ Object Dynamically Success/Failure Criteria for Software Projects AJAX Secutiry and AJAX Applications Accessible -- Many Tutorials and Articles A NHibernate Helper Kit Apache——Config WebDAV 3D Desktop Some Funny Development Methodologies -- XXX Driven Development Why I hate Web 2.0/AJAX? Here are some reasons...
MVP——Model-Viewer-Presenter
风满袖 · 2006-07-12 · via 博客园 - 风满袖

MVP——Model-Viewer-Presenter

Introduction

这里的MVP不是微软的那个MVP,而是一个设计模式Model-Viewer-Presenter。最早(2000年)由IBM开发出来的一个针对C++Java的编程模型,它是MVC模式的变种。其目的就在于提供a cleaner implementation of the Observer connection between Application Model and view

MVP

在企业应用中,对用户有用的是各种数据,他们通过UI以各种不同的方式管理这些数据。对于开发者而言,需要给用户提供各种UI,通过响应用户操作UI时触发的各种Event来执行一定的业务逻辑,从而操控数据,数据变化后还需要更新显示,给用户予以提示。UI是容易变化的,且是多样的,一样的数据会有N种显示方式;业务逻辑也是比较容易变化的。为了使得Application具有较大的弹性,我们期望将UI、逻辑(UI的逻辑和业务逻辑)和数据隔离开来,而MVP是一个很好的选择。

Model

MVC中的Model是一样的含义——The Domain Data,包括SelectionCommand

图:

Viewer

呈现Model,且处理UI的事件(Handle UI Event)。

Presenter

代替了Controller,它比Controller担当更多的任务,也更加复杂。Presenter处理事件,执行相应的逻辑,这些逻辑映射到ModelCommand以操作Model。那些处理UI如何工作的代码基本上都位于PresenterPresenter如同一个乐队的指挥家,表现和协调整个Application,它负责创建和协调其它对象。

ModelView使用Observer模式进行沟通;而PresenterView则使用Mediator模式进行通信;Presenter操作Model则使用Command模式来进行。从上面我给的链接MVP中可以找到讲解MVPPDF文件,该文档中详细说明了MVP的设计思想。

如果想知道MVCMVP有什么不同,那可以看这里

Example

光看理论还不能掌握一个架构模式,得看看实际的例子才行,我在codeproject上发现一篇不错的文章《Model View Presenter with ASP.NET》,作者指出了ASP.NETcode-behind编程模型的各种缺点,然后讲解了如何将MVP应用到ASP.NET Application中,而无须使用复杂的Framework

更多的例子:

http://www.mattberther.com/2005/01/000589.html

http://codebetter.com/blogs/jeremy.miller/articles/129546.aspx

http://weblogs.asp.net/pgreborio/archive/2005/01/07/348021.aspx

http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/default.aspx

如果不介意看smalltalk的话(其实关键是思想):

http://www.object-arts.com/docs/index.html?modelviewpresenter.htm

http://www.mimuw.edu.pl/~sl/teaching/00_01/Delfin_EC/Overviews/ModelViewPresenter.htm

另外还有一个Jean-Paul TV
http://weblogs.asp.net/bsimser/archive/2006/07/18/Model_2D00_View_2D00_Presenter-Pattern-with-SharePoint-Web-Parts.aspx

Postscript

MVC模式几乎是人人都知道的,但MVP似乎知名度小得多,很少有人提及。其实Martin Fowler讲解过该模式。虽然它创建之初是为了针对C++Java的,但在象C#这样的语言中也一样可以应用它。使用MVP后,我们可以提高对ModelPresenter的复用,比如可以对ModelPresenter不做修改,而能提供ASP.NET Web Form Windows Form。总之,MVP是一个值得去研究的架构模式。