Mvc Vs Mvp - Jinal Desai
While surfing for the differences between MVC (Model View Controller) and MVP (Model View Presenter) I found lots of confusion over the net. Also I found some differences between the two on some sites, but none of them have complete list of differences. Following is one attempt for compiling almost all the differences between the two patterns.
<ul><li> 1. Articles from Jinal DesaiMVC Vs MVP2012-05-27 17:05:29 Jinal DesaiWhile surfing for the differences between MVC (Model View Controller) and MVP (Model View Presenter) Ifound lots of confusion over the net. Also I found some differences between the two on some sites, butnone of them have complete list of differences. Following is one attempt for compiling almost all thedifferences between the two patterns. Parameter MVC (Model View Controller) MVP (Model View Presenter) View(UI), Model(Business View(UI), Model(Business Entities/Data),Structure Entities/Data), Presenter(UI Controller(UI Business Logic/Request Handling) Business Logic/Request Handling) In MVP Presenter is the supervisor In MVC Controller is the supervisor for responsing for responsing requests from view, requests from View, commanding/altering modelSupervisor commanding/altering model for for providing entities/data and decide the next view providing entities/data and return to display. user requested view.Supervisor and In MVP, Presenter is decoupled In MVC, Controller is coupled with View. ControllerView from view. Presenter talks to view is invoking next view through its concrete class.Decoupling via interface. In MVP, communication between In MVC, communication between View and View and Presenter(Supervisor) isSupervisor and Controller(Supervisor) is one way. View is two way. View is triggeringView triggering Controller actions, but Controller is not Presenter actions, and afterCommunication directly talking to view. It always go through the processing the request Presenter Model. updates View through interface. One View is mapped to oneView and Presenter only, because presentor Multiple Views can be mapped to single controllerSupervisor is updating View through interface. becuase Model is updating View.Mappings So, Presenter must be aware about which view to update/create. Passive Model: Employed when Controller is exclusively updates Model. The controller modifies the model and then informs the view that the Passive Model: The View is as model has changed and should be refreshed. The dumb as possible and contains model in this scenario is completely independent almost zero logic. The Presenter is of the view and the controller, which means that a middle man that talks to the View there is no means for the model to report changes and the Model. The View and Model in its state. The HTTP protocol is an example of are completely shielded from one this. There is no simple way in the browser to get another. The Model may raise asynchronous updates from the server. The events, but the Presenter browser displays the view and responds to user subscribes to them for updating the input, but it does not detect changes in the data on View. In Passive View there is no the server. Only when the user explicitly requestsFlavors: direct data binding, instead the View a refresh is the server interrogated for changes.Passive Model exposes setter properties which the Active Model: The active model is used when theand Active Presenter uses to set the data. All model changes state without the controllersModel state is managed in the Presenter involvement. This can happen when other and not the View. sources are changing the data and the changes Active Model: The Presenter must be reflected in the views. Consider a stock- handles user gestures. The View ticker display. You receive stock data from an binds to the Model directly through external source and want to update the views data binding. In this case its the when the stock data changes. Because only the Presenters job to pass off the model detects changes to its internal state when </li> <li> 2. model detects changes to its internal state when Model to the View so that it can bind they occur, the model must notify the views to to it. The Presenter will also contain refresh the display. logic for gestures like pressing a MVC pattern is mostly used with Active Model, button, navigation, etc. otherwise in Passive Model we are again introducing dependency between Model and Controller. Also supports maintainability and extensibility with true Separation of Supports easy maintainability and extensibility with Concerns. View and Presentor isAdvantages Separation of Concerns. Easy to unit test Model, decoupled so easily unit tested, in View and Controller at some extent. MVC in some scenarios it is difficult to mock test View independently. Best used for developing disconnected web Best used for rich UI applications.Usages applications. i.e. ASP.NET MVC, Struts and Java i.e. Web Forms/Sharepoint, Web Platforms. Windows Forms.Referenceshttp://nirajrules.wordpress.com/2009/07/18/mvc-vs-mvp-vs-mvvm/http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-differencehttp://joel.inpointform.net/software-development/mvvm-vs-mvp-vs-mvc-the-differences-explained/http://www.codeproject.com/Articles/228214/Understanding-Basics-of-UI-Design-Pattern-MVC-MVPhttp://msdn.microsoft.com/en-us/library/ff649643.aspx Blog this! Bookmark on Delicious Digg this post Recommend on Facebook Share on FriendFeed Share on Linkedin Share on Orkut share via Reddit Share with Stumblers Share on technorati Tweet about it Subscribe to the comments on this post </li> </ul>