Translate PresentationModel to ViewModel

Aug 14, 2009 at 9:21 AM

Today I translate PresentationModel to ViewModel in my project. I think it is easy to merge the presenter into the model, which we call it ViewModel now. During this working, I have some suggestions to p&p Team:

1. Let's call presenter-first as view-last, because some patterns lack presenter.

2. Does ViewModel need a Presenter? I find some persons use it in ViewModel, but I think in this way, ViewModel actually is a PresentationModel, although we still call this name.

Aug 14, 2009 at 10:35 AM

[jianqiang] 2. Does ViewModel need a Presenter?

Presentation Model and Model-View-ViewModel are synomonous.

Martin Fowler teaches us in his article on GUI Architectures in 2006 (about the time Microsoft's John Gossman coined the phrase MVVM for WPF) that the Presentation Model evolved from MVC,   the noted limitations of the Presentation Model "helped develop the Model-View-Presenter approach".  John Gossman introduces even more limitations in his Tales from the Smart Client article which suggest MVVM may not be well suited for small or Enterprise applications.

It is my experience with Enterprise level applications that PRISM, more specifically Dependency Injection, the Presentaiton Model opens the door for even more issues.  Reusability and loose coupling...   As Martin Folwer notes in his Presentation Model article, each view should have only one Presentation Model, Presentation Models can be shared by more than one View.   Since different views can have different algorithms for calculations the Presentation Model can become bloated and/or impractical for reuse and can lead to duplication (more complexity and inconsistencies) - reference "Patterns of Enterprise Application Architecture" by Martin Fowler, Domain Model (116).  

A Presenter levels the playing field.   Common entities and behaviors can be placed on a Presentation Model (reusable) and Presenters, using dependency injection, can specify the Presentation Model it will be using (loosely coupled).   Presenters can encapsulate domain logic that is specific to a use case.