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

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
量子位
博客园_首页
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Forbes - Security
Forbes - Security
IT之家
IT之家
N
News and Events Feed by Topic
S
Security Affairs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Webroot Blog
Webroot Blog
Recorded Future
Recorded Future
L
LangChain Blog
Y
Y Combinator Blog
AI
AI
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google Online Security Blog
Google Online Security Blog
V2EX - 技术
V2EX - 技术
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
I
Intezer
T
Tenable Blog
G
Google Developers Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
云风的 BLOG
云风的 BLOG
C
CXSECURITY Database RSS Feed - CXSecurity.com
有赞技术团队
有赞技术团队
O
OpenAI News
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
C
Check Point Blog
Last Week in AI
Last Week in AI
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
Blog — PlanetScale
Blog — PlanetScale

博客园 - 风满袖

如何进行有效的沟通(二) 如何进行有效的沟通(一) 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是一个值得去研究的架构模式。