MyVerbalOutlet

This is where I spout off about stuff

Archive for September, 2008

ASP.NET MVC Preview 5 is the release I have been waiting for from Microsoft.  The MVC team finally added easy model validation to the framework.  The new features are detailed at Scott Guthrie’s blog.  Validation was an issue that had previously hung me up when I dabbled with the MVC framework.  Model validation enables another business rules validation in a way that I thought was very elegant.  You can use partial classes to add business rules to a model class.  This allows your business rules to be separate from the model classes and if you regenerate your model classes you won’t overwrite your business rules.  I really like to see this because it means in my test project I can remove a layer of abstraction and keep the business rules close to the model classes.

I do have an issue with one of the new features in Preview 5 though and that is the [ActionName("action")] attribute.  In conjunction with the  [AcceptVerbs("POST")] attribute it allows you have different functionality for a URL depending on how its requested.  This is necessary functionality I just have issue with the way its implemented.  I would prefer to see something along the lines of this.

public object Create(string productName, Decimal unitPrice)
{
    if (Request.Verb == "GET")
    {
        return View("Create");
    }
    else if (Request.Verb == "POST")
    {
        // save the data RedirectToAction("List");
    }
}

I think this would make more sense.  You wouldn’t have the possibility of confusion as to what action to call your code.  You would always call the Create action.  If you started getting actions with a lot of lines of code in them you could just refactor the code in the if else statements into new methods.

  • 2 Comments
  • Filed under: Tech
  • Lost Styles

    I did something dumb and lost my WordPress theme.  All hail the mighty Google though for helping track down the name of the theme I was using.  I searched for a word in the title of one my recent blog posts and then clicked on the Google cache version of it and found the name of the theme I was using at the bottom of the page.  I still lost all the changes to the theme I had made but at least I have somewhere to start from.

  • 0 Comments
  • Filed under: Tech