Refactor CAB Smart Part Quick Start Project to ” Model View Presenter”
In my previous post, I refactored CAB Smart Part Quick Start project to use Presentation Model. This time I refactored the project to use Model View Presenter. Note: the Presenter class is borrowed from Smart Client Software Factory, SC-SF.
Download: Source for PM, Source for MVP
They can be added to Smart Part QuickStart Solution for comparison.
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,
I prefer PM to MVP. I successfully used the PM pattern in several projects.
My thougths are,
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.
The Smart Client Software Factory recommand MVP over PM, “The rationale behind MVP as implemented in SC-SF is to encourage unit testing …” Read this thread.
So, I created two projects for the two patterns. Next I will try to unit tests for them to see.
Add comment May 19th, 2006