Phil Haack posts about ASP.NET MVC

Phil Haack has a tutorial type post of usage of the new MS MVC with TDD, DI and the Repository Pattern. In the tutorial he sets up a new project, creates a repository and gets a sample app up and running with StructureMap.

As I stated in the comments of his posting there are only two things that concern me off the bat. The first thing is the fact that every action on controllers require a [ControllerAction] attribute. This is very descriptive of the controllers but really unnecessary. It adds a lot of extra typing for no real benefit. I realize they are trying to make sure that developers aren’t running around naked with scissors but descriptive documentation stating every public method will be an action would work better here. My hope is there will be some way to override this behavior.

The other thing that concerns me in the post is the way he is passing a parameter back to the view when calling RenderView like so: RenderView(“myview”, mycollection). I would imagine that they have a way to set parameters to an array like PropertyBag[] in MonoRail. Perhaps there is a way to accomplish this already. I haven’t really dove into the documentation for the new framework. I am trying to hold back until the CTP.

All this is great and excellent that a MS employee is now explaining how to use TDD with a new framework from MS. This is a great move on their part and I’m glad we’ve gotten this far. The new framework looks great and I’m sure it will do fine with the community.

Regardless of how awesome it looks, I do have to go back to an older posting that I wrote that describes at the end of the day, this is still a Microsoft technology. Therefore, there is no way you can take this framework and add features to it yourself, or fix bugs, or contribute to it. This fact alone makes me very nervous about using it. I don’t mean to get on an open source soap box here but these are the types of things I look at when choosing a new framework. Sure, it is made by MS, but how many times have you been burned by a MS tool? It just makes me nervous that this is not Open Source. The main reason that MonoRail has been so successful is because it is open source. They have an extremely large number of contributors that help make MonoRail successful.

Anyway’s, before I piss of too many people I will say farewell and I am very much looking forward to the MS MVC CTP which is coming very soon!

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Sean Chambers

I am a Senior software developer from Palm Coast, Florida. An advocate of Domain Driven Design, Behavior Driven Development, creator of FluentMigrator and community activist. I am married to my beautiful wife Erin and am the proud father of two wonderful children. I currently reside at ACI, a local insurance industry/mortgage software company that excels in creating solutions using Agile methodologies.
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.lostechies.com/blogs/joe_ocampo/ Joe Ocampo

    I agree with you on the usage of the [ControllerAction] attribute. This was something that I always loved about MR in that they took a convention over configuration approach. The less noise I have in my code the better.

    I don’t know how open MS is going to be with the ASPMVC framework but Jeffery Pallermo recently blogged about an OSS contrib project for ASPMVC. It looks like they are going to use this project to extend the capabilities of the ASPMVC. This may help solve your issue.

    http://www.codeplex.com/MVCContrib

  • http://haacked.com/ Haacked

    There is a propertybag approach. You can do this:

    ViewData["foo"] = new Bar();

    And reference it in the View as < %= ViewData["foo"] %>

    So you don’t have to pass in the object to renderview. However, if you do, you can take advantage of strongly typed access to your data.

  • http://weblogs.asp.net/scottgu ScottGu

    This blog post covers how to pass ViewData from a Controller to a View pretty comprehensively: http://weblogs.asp.net/scottgu/archive/2007/12/06/asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx

    There are two ways to-do it:

    1) Via a late-bound ViewData dictionary (like Phil showed above)

    2) Via a strongly typed object. The benefit of this option is that you get type checking and intellisense within your view.

    I cover both in my blog post.

    Thanks,

    Scott

  • Mike

    “It adds a lot of extra typing”
    Wow, great argument. Same goes for it being a Microsoft technology, the whole (ASP).NET framework is, yet I’ve been making a living programming it for 2 years now. So where’s the problem?

  • efdee

    @Mike: It’s about as great as “I’ve been making a living of it for 2 years now”. People make a living off selling crack on the street, what’s your point ?

  • http://www.lostechies.com/blogs/sean_chambers Sean Chambers

    @Mike

    So lets say you type out “[ControllerAction]” for each public action that you have. On a medium size project I recently built I had about 10 actions per controller and about 40 controllers across the whole project.

    18 Characters x 10 actions per controller = 180 characters PER controller.

    Across all controllers that is 7200 characters.

    Show me someone that doesn’t think thats alot of extra typing and I’ll show you a fool.

    Tell you what, you add all the ControllerAction attributes to all your public methods which will take you about 8+ hours and I will subclass it like Phil demonstrated and be done in 5 minutes.

    I make a living at programming it as well but if you don’t try to be more effecient then I can’t take you seriously. sorry.

  • http://www.lostechies.com/blogs/joe_ocampo/ Joe Ocampo

    @Mike just because we have been doing it doesn’t mean we have to continue.

    I hate to use this but we are like a bunch of lemming s sometime and we just fall in with the standard conventions.

    MR and RoR have been very successful with the Convention over Configuration approach. And I think for us to turn a blind eye towards this approach simply because MS want to change it is a diservice to the community.

    A majority of the MVC framework takes a convention over configuration approach. This slight decoration causes a shift in that way of thinking. It is not about a matter of style as it is a matter of adhering to framework principle no matter how esoteric they may be to new comers.

    The fact of the matter is all we are asking for is a choice and I believe Phil and the rest of the MVC team has given us this with the “ConventionController” so now it truly is a matter of style.

    Although I do like Scott’s suggestion about the controller defaulting to this behavior and forcing the “SafeMode” when needed. Similar to VB’s option explicit.