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

推荐订阅源

T
The Blog of Author Tim Ferriss
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
大猫的无限游戏
大猫的无限游戏
NISL@THU
NISL@THU
Scott Helme
Scott Helme
G
Google Developers Blog
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Cloudflare Blog
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
N
Netflix TechBlog - Medium
Hacker News: Ask HN
Hacker News: Ask HN
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cisco Blogs
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Forbes - Security
Forbes - Security
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
S
Security Affairs
B
Blog RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Privacy & Cybersecurity Law Blog
Martin Fowler
Martin Fowler
Know Your Adversary
Know Your Adversary
F
Full Disclosure
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
博客园 - Franky
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
T
Tenable Blog
V
V2EX
W
WeLiveSecurity
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

博客园 - 风满袖

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