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

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
J
Java Code Geeks
Jina AI
Jina AI
罗磊的独立博客
宝玉的分享
宝玉的分享
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园 - 叶小钗
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
B
Blog
V
Visual Studio Blog
雷峰网
雷峰网
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - yysun

Active Record Pattern 和 ORM 看看 EJB 3.0 的 O/R Mapping Unit Test : MVP vs PM - yysun test P&P OB CAB EntLib SQL/e WB Editor 2.5 is in beta - yysun 把图片存到 Flickr 与 Biztalk 搏斗 Manage Plug-ins 申请 WB Editor 2 注册码 SharpReader Plug-in AJAX WB Editor 2 的口号[yysun] 用 XSL 生成 HTML 日历[yysun] 用 XSL 重命名 XML tag name[yysun] XPathDocument 与 XmlDocument 结合使用[yysun] 再谈 JXPath 与 ObjectXPathNavigator[yysun] 用 WB Editor 连接 cnblogs.com 的全攻略[yysun]
Refactor CAB Smart Part Quick Start Project to "Presentat...
yysun · 2006-05-16 · via 博客园 - yysun

Composite UI Application Block (CAB) is really a powerful framework for smart client applications. It comes with samples implementing the Model View Control (MVC) pattern and the Model View Presenter (MVP) pattern. There is actually a third pattern called Presentation Model. See the pictures from http://jgoodies.com/articles/patterns-and-binding.pdf.

MVC MVP PM

As described in Martin Fowler's article (MVP, PM), the presenter in MVP has no state and the views need to provide interface allow presenter to manipulate them. The Presentation Model holds and synchronizes the state, but no need to create view interfaces.

Choice between MVP and PM, as per Martin Fowler's article:

This decision would be strongly influenced by a decent framework that supports such synchronization. If you have such a thing then Presentation Model seems the better choice.

The difference is that in MVP the presenter uses the interfaces to push data into the views. That presenter refers to views. In PM, views pull data from the presentation model.  Views refer to pm via interface. The pm implements the interfaces. Personally,

What esstentially MVP and PM do is to take the state and behavior of the presentation out of view. The views are dumb. They do nothing other than data binding and bypass user inputs.

But in MVP, although it splits one "autonomous View" into two parts, actually presenter and view are logically one thing, physically two class. When adding a new view, a new presenter is required.

In PM, it is a decoupled structure. Presentation model has no idea about view(s). It just holds the state and raise events. Adding new views needs no changes to the PM. View can also choose to connect different presentation model.

Compare to MVC or MVP, I prefer using the Presentation Model, because it has a centralized place to store state/data and centralized event source to notify views to update themselves.

The CAB's Event Broker is perfect for notification. .NET 2.0's object binding is perfect to synchronize state between PM and Views.

Tags: smart client Composite UI Application Block MVC Model View Presenter Presentation Model injection