This is a mirror of official site: http://jasper-net.blogspot.com/

Comparing the MVC and MVVM patterns along with their respective ViewModels

| Sunday, May 1, 2011
It won't take long in your quest to find more information on ASP.NET MVC through internet searches, with bing.com of course, before you'll stumble across the notion of a ViewModel. Mixed within those search results are links to articles on ViewModels in Silverlight/WPF, or other technologies that also use the MVC or MVVM patterns or ViewModels, which can be quite confusing. Having said that, it's no wonder in every presentation I give concerning MVC or ViewModels, a few folks frequently ask these two, quite reasonable, questions: 

"What's the difference between MVC and MVVM ?" (in general)
"What's the difference between ViewModels in MVC and ViewModels in MVVM?"
The elevator pitch: MVC is a web UI pattern, and ASP.NET MVC is Microsoft's implementation of it. MVVM is Microsoft's implementation of a desktop UI pattern in WinForms, SilverLight or WPF.

MVC is an old pattern, in use for decades in non-Microsoft platforms, and MVVM is a pattern similar to Martin Fowler's Presentation Model (PM) pattern, as it has taken many of its concepts from PM.

It's all about the patterns

Both MVC and MVVM are patterns, meaning that they are solutions to recurring design problems in software development. Patterns can show interactions between objects in various ways, as the few listed below will demonstrate:

General interactions
Interaction through inheritance and OOP principles
UI interactions
Interaction between models, views, and controllers or models, views, and ViewModels
Data access patterns
ORM mappings, Active Record pattern, POCOs in DALS
Once you're aware of patterns, you can then apply them in software to make your code more stable, consistent, and maintainable. A variety of tools and frameworks exist that can easily help find the best pattern and/or implementation for your specific business problem/domain. In particular, the MVC and MVVM patterns are both UI interaction patterns with MVC being the web UI pattern and MVVM being a desktop UI pattern. You can implement either pattern in Visual Studio, and the ASP.NET MVC project template in particular guides developers to use the MVC pattern.

In addition to MVC & MVVM there are many patterns that are worth reading up on.

Comparing MVC and MVVM: the patterns.

Since MVC and MVVM are geared towards different application paradigms altogether, i.e., ASP.NET MVC for web and MVVM desktop, they need to behave in distinctly different ways, with the most noticeable distinction being the controller from MVC... 

Read more: Rachel Appel

Posted via email from Jasper-net

0 comments: