Geeks With Blogs

News INETA Community Speakers Program
GeeksWithBlogs.net: WTFNext's hosting!

View Stacy Vicknair's profile on LinkedIn


WTF Next? Dev ramblings from a master of nothing.

When we talk about UI Architecture, a common theme of Model-View-Something continues to come up. The question is, however, what is the something? Am I working with Model-View-Controller? Model-View-Presenter? Something else?

The purpose of this blog is to explore the difference between MVC / MVP to give you an understanding of what they mean to accomplish, what are the differences and what situations best cater to each.

 

Does it really matter?

Does the difference really matter between MVC / MVP? Well, in purpose it hardly does. When we implement MVC / MVP we have the same goal: separation of presentation from the data model and synchronization of data between the model and the view. These goals are achieved by both patterns.

In implementation there is a slight difference.

 

Model-View-Controller

The MVC pattern originated in a time where every individual element of a display was managed by custom code. The view was literally the rendered representation of the model and the controller handled the inputs from the user to interact with the model. The model would then inform any concerned views or controllers via the observer pattern. Naturally, MVC lends itself to the situations where the interactions of the user are immediately translated into actions against the controller.

In .NET the ASP.NET MVC framework caters best towards MVC. With ASP.NET MVC the application receives a request for a specific URL. The URL is interpreted to determine a specific Action associated with a specific Controller. The Controller executes the action then returns a View that renders a representation of the model.

 

Model-View-Presenter

MVP was introduced alongside the concept of “widgets” or the more familiar notion of controls. Like the controls we use today in WebForms and WinForms, these early “widgets” were capable of understanding the user input on their own and delegating events as they arise. As a result, in the “widget” space our actions are translated into events that happen on the View itself that must be passed along, rather than handled immediately by the controller. As a result, Views have a tighter coupling to a specific Presenter because of the need to delegate information. This usually lends towards a one-to-one relationship of Presenters and Views.

The presenter in MVP also takes a more “hands on” approach than with MVC’s controller. Usually the presenter will have access to manipulate the view rather than the view talking directly to the model. This leads to the tighter coupling between the presenter and the view in MVP as opposed to MVC, but an interface is usually used as a layer of separation.

As with its origin MVP caters towards the .NET platforms that support built-in controls. This includes both ASP.NET WebForms and WinForms.

 

That’s all, right?

What I hope you’ve gained from this blog is enough to identify the goals and slight differences between MVC and MVP as well as the areas in .NET development where they apply. Check out the references below for a little more information about each and their differences!

References:
http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html
http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html
http://martinfowler.com/eaaDev/uiArchs.html
http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx

Technorati Tags: ,,,
Posted on Thursday, September 29, 2011 9:24 AM | Back to top


Comments on this post: Model-View-What?

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Stacy Vicknair | Powered by: GeeksWithBlogs.net