Or rather a ‘what have you been doing lately’?
As usual I’m exploring areas around IoC/DI containers, jQuery, and MS MVC.
I had a chance this weekend to plug in some MS MVC time and I’m happy with the results. This is the way that web apps should be built. No question in my mind. There is a reason that MVC has carried over the years. The ability to setup REST urls in the routing, controller first capability of wiring up objects to the view, and Html ‘helpers’ using the new .net extensions is too much to resist. The only issue I’ve run into so far is with REST urls and encoding/decoding. In my sample at home, I have a value of 4.JG53/Recon – the ‘slash’ here messes up the REST.
…/ShowPilots/4.JG53/Recon <- doesn’t work.
I tried encoding it to be 4.JG53%2Recon – but it takes that and decodes it back to the slash – oops. I’m investigating this one, outside of saying ‘don’t pass names like that’ 🙂
Lastly, back to IoC. My links today will show an example of how to build your own. Sure, it’s just a start, but it’s a good way to show the underpinnings of IoC. Microsoft P&P team released Unity in beta, it still has work to do in my opinion. The use of attributes for setter injection is just wrong to me. I don’t want to decorate my classes showing setter injection. To me, it shouldn’t be in my POCO classes. I’d rather wire them up in xml, than place that on my classes. Secondly, for the life of me I cannot find out how to set default values – ie. I pass in the connection string to my dao objects. I’ve used the container to store my connection string, setting it on the constructor. I cannot find this in Unity – maybe I’m missing something 🙂 So, when it came time to do the MS MVC, I ended up switching back to Castle’s Windsor. It’s just so rich and so easy at the same time that it’s too hard to resist.
Ok, on to the links:
Build Your Own Container – Part I
Build Your Own Container – Part II
MSContrib – very nice user community contributions including support for Windsor, Spring – new view engines, etc..
MS MVC – Design Philosophy
MS MVC Toolkit
Scott Guthrie’s 5 Part – how to’s (excellent starting place)
Part I – What is It?
Part II – Building an MVC Application
Part III – URL Routing
Part IV – Passing ViewData from Controllers to Views
Part V – Handling Form Edit and Post
Using JQuery with MS MVC
Just a simple example – but it shows how simple this is. So much better than dealing with the webforms leaky abstraction, id munging, complex postbacks, etc…