So I just rolled off a project I’ve been on for awhile and I’m taking a few days to dig a bit into the ASP.NET MVC framework, now in Preview 2. Some good material came out of the MIX conference, including a particularly great presentation from Scott Hanselman. If you are starting from scratch, that’s a pretty good place to start. You can either download a WMV or watch it streaming. In addition, there is now a whole section on the main ASP.NET web site dedicated to MVC with resources, forums and so on. A lot of other articles and blog posts are starting to pop up as well, so if you are a little intimidated about jumping in there is starting to be some support.
As I’ve mentioned before, I’ve been working with ASP.NET since the pre-beta and have mostly kept up with the various changes to the framework over the years. There are aspects of ASP.NET 2.0 that I wouldn’t consider myself an expert on, but I at least know the basics for most features and where to find information if I need it. I say that because I expect a lot of ASP.NET developers are in a similar boat with me when it comes to MVC. I’ve worked on a lot of enterprise web projects, including several version conversions. I’ve used a bunch of the betas. But I’ve generally stuck to the Microsoft provided “bits”, partly for client needs for maintainability and understanding of code and partly to avoid some of the risk of a new version breaking a bunch of custom or 3rd party code not controlled by Microsoft. So I haven’t really dug into the ALT.NET side of things. Played a little with stuff like Cruise Control, log4net,some code generators and so forth. Understand the very basics of TDD,but haven’t really found a very good way to do it on the traditional ASP.NET side of things. Anybody out there in the same boat?
So anyway, call me chicken, but now that Microsoft is working on an MVC stack I’m finally willing to take a look. Scott Guthrie has really gathered some good people on his various teams over the past few years and I really think they are trying to do the right thing when it comes to community input, transparency and willingness to try new things. So the MVC bits aren’t really even close to done, but they have accomplished a lot in a short time. I think there is still a lot of question about where this fits into enterprise development and what types of applications are best suited to this approach. The types of applications many of us write involving heavy reliance on viewstate, sessions, event wireup and now AJAX don’t always map nicely or clearly to an MVC approach. That’s not to say they can’t be done, but the best practices jury is still out in a lot of cases. That being said, test-driven development maps so nicely to this approach in a way that wasn’t possible before, so that alone to me makes it worth a serious look when designing a new web application. Because it really isn’t terribly easy to do this with traditional ASP.NET (other than some type of grand automation scheme that still requires a web server), a lot of web developers, myself included, have basically thrown up our hands and haven’t really even tried.
There are a couple of other features of the MVC stack that I like a lot. Maybe not features even as much as a philosophical approach. Here are a few highlights:
- Separation of concerns, as Guthrie talks about a lot. Real n-tier development. Mockable interface-driven web sites.
- Extensibility. There is a real effort to include other test frameworks, view frameworks, etc in the flow. Or write your own.
- Routing. This is super cool, allowing you to separate your view logic (think web pages in traditional sites) from the actual url. Create urls your Mom can remember. Move things around without breaking anything.
One more thing, if you want to learn the new language features like LINQ, lambda expressions, anonymous types, etc., these things are all over the place in the MVC framework. And for me, the way they are used really helps me understand the power of these features and how you might use them in a real application. Many of the walkthroughs or blog posts point these out, so it’s a good way to introduce yourself to some new stuff.Comments Off , permalink