Revisited: MVP Framework

A couple of months ago I blogged a series of posts on a small Model-View-Presenter Framework I was working on for ASP.Net (here, here, and here).  At the time it was mostly wild theory bolstered with code that compiled :)  I'm proud to say I now have an application using my Framework that is just about ready to go to production.  woot!  I got a comment on one of the older posts asking for an updated working example and felt that now was a good time to oblige.

As with any theory the actual implementation yielded some things that worked well and some things that did not work so well.  One of the ideas that did not work so well was housing the View components (.ascx file) in a separate assembly, precompiling, and merging with ILMerge.  These tasks were part of an AfterBuild event that would then copy the resulting output to the bin directory of the Web project.  I had problems running the Web project in Debug mode because Visual Studio (with Web Application Project) insists on re-building the solution even if there have been no code changes.  I ran into strong naming and version mismatch problems because certain assemblies used 1.0.0.* So the View project would build with references to other assemblies that were 1.0.0.12 then the Web project would be re-built to run in Debug causing other referenced assemblies to be rebuilt to version 1.0.0.13 and mayhem ensued.  I could have turned off the automatic build revisions but use those for other purposes.  The ultimate solution was to move the Views back into the Web project and be done with it.  There was minimal value added in having these components in a separate assembly.  The framework still supports pre-compiled Views but has the added ability to support standard .ascx Views by specifying a VirtualPath attribute when adding the component to the container. 

<component id="DashboardView"    service="BatchTracker.Interfaces.IDashboardView, BatchTracker.Interfaces"
type="BatchTracker.Views.DashboardView, BatchTracker.Web" virtualPath="~/Views/DashboardView.ascx"
/>

The code download includes examples of both implementations.

What has turned out to be the shining star of the Framework is the KeySearchNamingSubSystem (formerly called DynamicNamingSubsystem).  This little gem has been invaluable for its ability to inject dynamic components based on runtime parameters.  In a nutshell this subsystem allows the Kernel to return different service implementations based on query string parameters, allowing a single hosted application to provide interface and logic customizations to hundreds of customers without changing the base product.  For the full details as well as usage notes (specifically the use of non-transient components) read the linked article.

Download the sample application here.

I'd love to hear from anyone who has experimented with my little project.

posted @ Sunday, December 24, 2006 2:45 PM


Print

Comments on this entry:

# re: Revisited: MVP Framework

Left by Billy McCafferty at 4/23/2007 11:40 PM

Bill,<br /><br />How's all this working out for you these days? I'm starting a new, multi-year project in the next month or so and am re-evaluating my MVP/MVC options. I've been using the guidelines I wrote about at http://www.codeproject.com/useritems/ModelViewPresenter.asp which has been working well. But I still get that "yucky" feeling every once and a while because of the soft border between views and presenters. I love the idea of MonoRail, but I don't want to give up all my telerik controls. What're your latest thoughts?

# re: Revisited: MVP Framework

Left by Ayende Rahien at 12/24/2006 6:00 PM
Gravatar

I am not 100% sure, but does the naming subsytem has access to the rest of the attributes on the component, IIRC, it should just goes away, shouldn't it?<br /><br />Anyway, that is some really cool idea that you have here!

# re: Revisited: MVP Framework

Left by Bill Pierce at 12/24/2006 6:57 PM
Gravatar

Finally back from the Reserves? I've been going into withdrawls because I haven't had my daily Ayende blog fix :)<br /><br />Forgive me since I don't exaclty follow your statement about the naming subsystem having access to component attributes.<br /><br />My WebUserControlComponentActivator uses the 'virtualPath' attribute when instantiating an ascx component. The KeySearchNamingSubSystem uses a delegate to dynmically determine which component to return when requesting a component by service in the case where there are multiple implementations of that service in the Kernel.

# re: Revisited: MVP Framework

Left by Willie Tilton at 12/26/2006 4:45 PM

Just wanted to let you know, you guys are starting to build a club of elite nerd nerds. I have no idea what you guys are talking about so I will go back to my simple-nerd cave to meditate. One day I will understand, but that certainly isn't today.

# re: Revisited: MVP Framework

Left by Jason Krell at 1/3/2007 8:20 PM

Bill -<br /><br />I would like to look at your sample application, but when I download the zip, it is empty. I tried various machine/browser combos, all with the same result.<br /><br />Your blog posts are very interesting, and I am looking forward to the day I can get my head around this stuff.<br /><br />If you could repost the zip, or email me at {firstname}.{lastname} at gmail, I would really appreciate it!<br /><br />Thanks,<br />Jason

# Concise Introduction to Castle MonoRail

Left by devlicio.us at 5/29/2007 6:43 PM

Your comment:



 (will not be displayed)


 
 
 
Please add 5 and 3 and type the answer here:
 

Live Comment Preview:

 
«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456