Presenter vs. PresentationModel vs. ViewModel vs. Controller

Topics: Prism v2 - Silverlight 2, Prism v2 - WPF 3.5
Jun 12, 2009 at 1:48 PM

I'm new to the Prism framework and after much study I'm left with a few questions regarding the when / where to implement the following patterns. Meaning... "time to add a module..." what drives the decision to use one pattern over the other?

  • PresentationModel - The data context of the view but can contain presenter responsibility
  • ViewModel - A.K.A PresentationModel?
  • Controller - Not the data context of the view but contains presenter responsibility
  • Presenter - A.K.A Controller?

Ugg... just searching for clarity.

Jun 12, 2009 at 6:26 PM

Hi,

 

The PresentationModel and ViewModel (MVVM) pattern are a synonym when talking about Prism. However, the MVC and MVP patterns are not. The choice of which pattern to implement greatly depends on your application’s needs and your comfort using each of them. The MVVM pattern, leverages the data binding capabilities of WPF/Silverlight to reduce the amount of code behind in the view. In the MVP/MVC patterns, the view has to communicate with the Presenter/Controller (via a reference or events exposed through its interface), which handles the complex logic of the application. This in the code behind of the view.

 

Have in mind that one of the important advantages of these patterns is the testing capability they offer, by decoupling the presentation logic from the view. Thus, how much code you will be able to test with each pattern might also affect your choice.

 

You can read more about this patterns searching the Web (I personally recommend Martin Fowler’s explanation, you can search the Web for it). Below I will provide some extra links that might make things more clear:

·         WPF Apps With The Model-View-ViewModel Design Pattern

·         Model View Presenter

·         Model-View-ViewModel In Silverlight 2 Apps

·         Interactive Application Architecture Patterns

 

Please let me know if this helps.

 

Damian Schenkelman

http://blogs.southworks.net/dschenkelman

Jun 16, 2009 at 1:22 PM

Thanks so much Damian. This certainly drove the ideas home for me.