Refactor cab smart part Quick Start Project to "Presentation Model"

Source: Internet
Author: User

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.

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 demo-wowould be strongly influenced by a decent framework that supports such synchronization. If you have such a thing then Presentation ModelSeems the better choice.

The difference is that in MVP the presenter uses the interfacesPushData into the views. That presenter refers to views. In pm, viewsPullData 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 inform y 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.