Craig Shoemaker over at Polymorphic Podcast has created a series of short webcasts on the Model-View-Presenter design pattern. I spent some time tonight looking through them and was pretty impressed with the topic overview.
While I have heard others discuss the MVP design pattern and its benefits, I have neither implemented it myself nor seen it implemented in any concrete fashion. So I went into the webcasts with some skepticism to determine whether the pattern was as useful as I had been told.
After watching the first webcast, my initial reaction was, “Why would people want to write all that extra code? Just to say they had another layer of abstaction? I could never sell anyone on this idea!” But I decided to watch the second webcast, which took the first project (a web project) and applied the Presentation (Presenter) and Business (Model) layers to a new WinForms application. Without a single change to either of the two aforementioned layers, Craig was able to re-create the UI functionality with minimal coding changes.
Now, granted, the examples are a bit vanilla and more real-world projects will require additional forethought. And, as with everything else, this design pattern is no silver bullet. However, I can say with certainty that I am a bit less skeptical of the MVP design pattern after watching these webcasts.
Thanks for the webcast links. This topic is near and dear to my heart…
3 reasons I use this pattern:
1. No defects in your user interface – I’ve noticed that the lowest quality code of most systems is the user interface. Low quality leads to defect and defects make me do support. I don’t like support!
2. It clearly divides the presentation logic from the business logic
3. This pattern taught me how to decouple my designs. I apply the same concepts whenever I have a class that collaborates with multiple external system (file system, database, and/or webservice)