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.