Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Listen to the Show!

Didn't you know about my true love for dance? :)


This show features an interview with Software Management Consultant and CTO of Headspring Systems, Jeffrey Palermo. Jeffery takes us through the current state of the ASP.NET MVC framework and explains how to construct an MVC website and delves into some of the relevent controls that make up the framework.

What is the ASP.NET MVC Framework?

The ASP.NET MVC Framework is a new effort from the ASP.NET team to adjust the architecture of web applications to more closely resemble what you find in MonoRail or even Ruby on Rails. The logical portions of a page are separated down natural lines of differentiation. Code responsible for "modeling" your domain is separated from code that handles interaction among busines objects which is still separate from code that presents data to the user. For more information about the Model-View-Control ler design pattern (MVC) please refer to the following resources:

MVP in light of the ASP.NET MVC Framework

The rise in interest in the ASP.NET MVC Framework has many people wondering where the Model-View-Pre senter (MVP) pattern fits in to the mix. We have spent a lot of time on the Polymorphic Podcast thinking about MVP in not just one, but two podcasts and a series of 5 how-to screen casts.

Some interesting ideas are floating about on some podcasts and blogs lately regarding the purpose of ASP.NET MVC and the value of MVP. Further, I recently received this email from listener Buddy Stein trying to reconcile the ASP.NET MVC and MVP patterns:

Craig,

You've made a convert of me to the MVP pattern, but after listening to your interview with Scott Hanselman, I couldn't help but think he's "drinking the Microsoft Kool-aid".

If the MS MVC framework only works with asp.net, then why bother? Just stick with code-behind and save the trouble.

Isn't the whole point of the extra MVP effort; that you can re-use your code for winforms and asp.net? If your coding to the lowest common demoninator by coding for both platforms as Scott states. Then please enlightenment me what we can't do in ASP.NET or Winforms because were using the MVP pattern.

Craig, If I'm wrong, tell me, but I'm a corporate developer and I'm convinced that the combination of MVP and TDD are the most professional approach to .NET programming today.

Buddy Stein

In response to Buddy's points, I suggest we consider the following:

  • ASP.NET MVC is not mandatory: The ASP.NET team is working hard on making the MVC Framework the best it can be, but it is not a replacement for WebForms. If your application is better suited as a traditional WebForms project, by all means use it.

  • ASP.NET MVC is about more control: The changes we see coming up in the MVC framework is increased control in your site's URLs, cleaning up HTML with the ditching of ViewState, coming out from under web controls and letting the developer easily dictacte the HTML sent to the browser. On top of all of this you have true testibility of the UI for the first time in Microsoft web technologies. The reasons to use ASP.NET MVC are more compelling than a mere replacement of code-behind.

  • Theory is different than practice: One of the questions I had for a long time when ASP.NET MVC came out was, "Why target an MVC framework to ASP.NET?" Scott Hanselman makes an interesting point in our interview where he basically states that an MVC framework fine tuned for the web may not pay the same dividends in other environments.

    While we would all like to write features that may be automatically re-purposed from windows to web and vice versa that is a tall order. True, MVP gives you the building blocks to create an controller you can use in any environment, but there is a lot of fine-tuning required to effectivley deal with state and resource management among the different environments.

  • ASP.NET MVC & MVP can play nice: If you really think about it the ASP.NET MVC Framework does is give you an alternative to the traditional code-behind model. ASP.NET MVC is better separated and more testable, but that doesn't mean you can not still implment a presenter underneath the ASP.NET MVC controller class. Think that is overkill? For some applications it's total crazy talk. If you have an enterprise application that must weather the storm of changing technologies from year-to-year, then you might want to consider it. Just stop of a second and think about the lines of code you have stitting in WebForm code-behind files... now if those pages were implmented using MVP how hard would it be to make that site an ASP.NET MVC project if necessary?

What this all boils down to is that in the end you need to use the right tool for the right job... something I have advocated for a long time.


A Seriously Special Music Episode

As if the "Lambada" goof wasn't enough, this show I even more music for you! This show is packaged (at no extra cost) with "Seriously" from Greenleaf Avenue. Greenleaf's lead guitar player is one of my good friends Sol Rodriguez. Sol and his boys have entered a battle-of-the-bands type contest through a Los Angeles radio station.

If you like rock music I would love if you could take a minute and vote for "Seriously" from Greenleaf Avenue. You have heard some of Greenleaf's music peppered thoughout different episodes of the Polymorphic Podcast as bumper music.

Please note, the voting process does require a valid email and you have to click the confirmation link in the message they send you...

Try before you buy? You can check out a video the band produced for the song below...

Vote for "Seriously" from Greenleaf Ave here!

Published Thursday, December 6, 2007 2:01 PM by craigshoemaker

Comments

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Friday, December 7, 2007 9:24 AM by Tim Murphy

Craig,

I'm glad to be able to leave comments (read as smart-ass comments) again. :)

I don't think I mentioned it before, but congrats on the new job.  Of course it seems the last one didn't last very long. ;)

Keep up the good work,

Tim

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Friday, December 7, 2007 9:32 AM by craigshoemaker

Thanks Tim!

As far a the jobs go... sometimes you have to realize when something isn't for you and makes changes fast. Besides the Infragistics gig was just too good to pass up :)

Craig

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Wednesday, December 12, 2007 8:40 AM by Mike

I love the shows and I am new to the site. I dowloaded the code for MVP, and I was wondering why you decided to use events to communicate to the presenter.

event EventHandler<EventArgs> Save;

chould also be a public Save(...) method on the presneter.

Is there a reason? I usually keep my interfaces with only getters, setters...

Thanks.

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Monday, December 17, 2007 10:37 AM by Craig Shoemaker

I like using events because that way the interface is responsible for abstracting the user interface. This keeps the coupling between the UI and presenter low. This really is more of a preference thing in the end.

Craig

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Monday, December 24, 2007 12:34 PM by Adron

I dig this entry, surprised I didn't find it before.  I ran into a similar discussion about the pros and cons of MVC/MVP/Code Behind/Front Controller usage before.  Based on the changing needs or non-changing needs of an application.

Fortunately guys that new about it better than me finally swooped in and helped save the day!  I am relieved though as I see MVC/MVP/Front Controller/Code Behind knowledge spreading though, I prefer not to have battles of logic and reason without everyone properly informed.  Usually there is no battle when all parties have all the information.

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Wednesday, August 13, 2008 2:07 PM by King Wilder

I'm about to start a large enterprise application and I'd like to use some sort of MVP pattern, because I want to continue to use my Telerik controls.  :^)

But my question is, in my ASPX page (View) I will generally create many UserControls (ASCX) that will contain reusable form bits.  Is there a way, using MVP, to dig into the UserControl and get and set data?

And what if I do a Page.LoadControl("some.ascx")?  Can I get into that control?

# re: Podcast: ASP.NET MVC and the Future of Model View Presenter : Interview with Jeffery Palermo

Wednesday, August 13, 2008 2:18 PM by craigshoemaker

King:

What about instead of setting the values from your presenter to regular server controls passing them to the user control?

If your user control is simply a wrapper for a few UI controls that may work... otherwise I have just made a presenter for the user control itself...

Does this make sense?