Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
2  
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 '11 at 16:21
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
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. –  Hasan Khan Oct 15 '11 at 3:27
add comment

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.

share|improve this answer
    
+1, one of the better descriptions of the nuances between these very similar concepts. –  Wyatt Barnett Oct 14 '11 at 21:21
add comment

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.

share|improve this answer
    
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 '11 at 18:36
    
@Falcon - sorry, I keep forgetting that –  Scott Whitlock Oct 15 '11 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 '11 at 8:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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