9

Today I was having a discussion with a colleague that ViewModel is a general concept and existed before MVVM pattern.

I believe ViewModel term is used anytime you create a class with Model like properties for showing on View that supports data binding like in ASP.NET and even in WinForms.

Is the opposite true? Did Microsoft name it the first time with MVVM?

1
  • 3
    I don't know if they named it first, but I'm using it for ages, way before I knew about MVVM. This pattern is pretty old.
    – deadalnix
    Oct 14, 2011 at 16:21

3 Answers 3

4

The MVVM is a specialization of the Presentation Model pattern by Martin Fowler. The Presentation Model pattern is platform independent and MVVM was created to take advantage of the capabilities of WPF (and later on Silverlight).

The Presentation Model was published in 2004 and the MVVM was first presented in blog posting in 2005 by John Grossman.

1
  • So it appears that VM term was coined by Microsoft, the concept was documented by Martin Fowler and the pattern may have existed well before that. Oct 15, 2011 at 3:27
12

MVP, MVC, MVVM, it's all VERY similar. The difference is mainly in exactly where certain things happen, and exactly what layer the user interacts with:

Thick Client/Smart Client - The View classes are the "god object". The code immediately behind the displayed UI knows everything it needs to in order to do its job, including having knowledge of the domain, possibly the DAL (if not using Active Record), and most rules concerning data validation. Most WinForms apps use this architecture, and even many "vanilla ASP.NET" apps have a very thick layer right up against ASP's HTML generator that handles most of this.

MVC - The Controller is the "god object". It is the object most directly interfaced with by the user, and generates or updates an extremely "dumb" presentation layer (View) based on business logic that gives it knowledge about the Model. The Model may contain higher business logic or it may concern itself only with data integrity. The best example I can think of is in video games; the user sees a video screen with the action happening, but for the most part doesn't work directly with that View to do something. Instead there is an HID in his hands, and when he uses it, signals are sent to logic within the Console which incorporate that data and refresh the screen. Some may argue that any app that uses a mouse or keyboard is MVC by this definition, but I would counter that from the concept of the application's top layer (and not the OS on which it resides), wherever there is a cursor or pointer that is the direct target of input via an HID, that is an abstract representation of the user's own hand that interacts with the UI elements.

MVP - The Controller of MVC is replaced with a less-powerful, more single-purpose Presenter. The Presenter still acts as the intermediary between View and Model, but the View often gains a few responsibilities, such as UI event handling. The Presenter acts to provide the View with necessary data from the Model in an easy-to-absorb fashion; either DTOs or bindable properties. This architecture allows for separation of concerns in GUI apps versus Thick/Smart Client architecture, while still allowing the UI to be the layer with which the user is conceptually interacting, and can be accomplished with most languages/architectures.

MVVM - The Presenter gains back some responsibility from the View and becomes a "binding source" for the View. The View provides only the most basic logic, relying instead on "binding points" available on the ViewModel. All the View knows how to do is get and set information provided by "data bindings", and invoke logic exposed through "event bindings". MVVM as a term was coined by Microsoft to describe the Windows Presentation Foundation, in which the View is structured based on XAML markup files that are given logic through defineable bindings to the ViewModel class.

2
  • +1, one of the better descriptions of the nuances between these very similar concepts. Oct 14, 2011 at 21:21
  • I have to say, that's a remarkably good and concise explanation. It's a shame it's hidden under a question that is a lot more specific (possibly even a bit unrelated).
    – tne
    Aug 6, 2014 at 12:45
1

MVVM is generally accepted to be a derivation of the Presentation Model.

There is a reference to a View model from systems engineering, and I would say they're related, but it's not the same thing. In the systems engineering View Model, it's a model of all the different Viewpoints. The ViewModel in MVVM is more like a model of one viewpoint.

I found this ASP.NET MVVM framework from 2009. However, I still think that was influenced by WPF's MVVM.

I can't seem to find references to ViewModel in ASP.NET stuff predating that. I wouldn't rule it out though.

3
  • A Presenter does not necessesarily know about the view imho. It depends on where you put the glue code. The view could just observe the presentation model. Martin Fowler makes a distinction between MVP and Presentation Model. MVVM is the latter.
    – Falcon
    Oct 14, 2011 at 18:36
  • @Falcon - sorry, I keep forgetting that Oct 15, 2011 at 1:03
  • Those GUI architectures are often very similar, only with slight differences. Confusing at times to anyone but Martin I guess :)
    – Falcon
    Oct 15, 2011 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.