Tuesday, July 19, 2016

MVVM pattern: Why ViewModel is called ViewModel?

I was thinking why the hell ViewModel is called ViewModel. I found two MSDN blog posts (1, 2) and finally I have reached my enlightenment: ViewModel is "A View for the Model". and "A Model for the View".

The View requires understandable data to show.
The Model has some data (that may not be understood by the View).

The ViewModel is "showing" data from the Model to an external world (i.e. the View) in understandable format (API). That's why I am calling the ViewModel as "a View for the Model".

The View is showing data from the ViewModel to an external world (i.e. a human being) in understandable format (GUI). That's why I am calling the ViewModel as "a Model for the View".

That sounds oversimplified, but still good answer on "Why the hell ViewModel is called ViewModel".




image

Image is taken from the great comparison MVC vs MVP vs MVVM:
https://blogs.msdn.microsoft.com/erwinvandervalk/2009/08/14/the-difference-between-model-view-viewmodel-and-other-separated-presentation-patterns/

Post a Comment