Tuesday, June 7, 2011

MVC, MVP and MVVM

MVC, MVP and MVVM are patterns, or more specifically architectural patterns, which specify guidelines (or recommended practises) for defining layers within an application and their communication styles for effectively maintaining, scaling, testing, etc the application and its layers.

MVC - Defines 3 layers i.e. Model, View and Controller. Controller receives the UI events and accordingly guides the model and/or view to update themself. And in case the Model is updated from other sources too, it can notify the View(s) to refresh themselves via the observer pattern.
For more details, please refer the following MSDN link:-
http://msdn.microsoft.com/en-us/library/ff649643.aspx

MVP:- is a variant of MVC, with the primary difference that there is no interaction between View and Model. And the Presenter interacts with the View via an interface.
For more details, please refer to following article by Dino Esposito:-
http://msdn.microsoft.com/en-us/magazine/ff955232.aspx

MVVM: Model ,View and View Model is very similar to MVP pattern. Or it is some sort of specialized form of MVP pattern. Here Presentator is known as ViewModel.
Model communicates with ViewModel with notification and ViewModel communicates with View with data binding and command .
Following article gives idea of MVVM at high level:-
http://www.codeguru.com/cpp/cpp/cpp_managed/general/article.php/c18913


Also the following link, too gives decent links to various details about MVC and MVP (some video links too are referrred):-
http://social.msdn.microsoft.com/Forums/en-US/modelingandtools/thread/eecc7b01-cee0-4c20-9086-b1c4cafa6709

2 comments:

  1. MVC:-

    View is only concerned with generating and presenting a UI so users can communicate intent to the Model.

    Controllers are the orchestrators who translate UI inputs into actions on the Model and pass back output from whatever View has been made aware of the Model(s) its presenting. Controllers must define application behaviour only in the sense that they map user input onto calls in Models, but beyond that role it should be clear all other application logic should not be contained within the Controllers. Controllers are lowly creatures with minimal code who just set the stage and let things work in an organised fashion.

    Model is not just the database. Even the data you get from web services can be expressed as a Model! Yes, even Atom feeds! Data Contracts/Entities and Data Access layer are also part of Model.

    ReplyDelete
  2. MVC -

    MVC:
    Learn MVC ( Model view controller) step by step 7 days http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in-7

    Video series from youtube step by step MVC:
    https://www.youtube.com/playlist?list=PL33C9E91F8CDD2BF7


    ReplyDelete