Archive | Tech RSS feed for this section

Herding Code Podcast

27 Jan

I listened to the Herding Code podcast number 69 today and it was bad. The guest Scott Bellware was ostensibly talking about the difficulties of working with what he called “HTML specialists” and everyone else calls designers. However he talked in such generalities and used such vague examples that he made no sense whatsoever for almost a half hour. Once he started talking a little less like a consultant trying to flim-flam his audience it almost became listenable. I hope in the future the Herding Code guys try and elicit more concrete examples from their guests instead of letting them ramble on.

Scott Guthrie Throws Some Water on the Web Forms/MVC Debate

26 Jan

Scott Guthrie wrote a very good article on about how to have a reasoned technical debate in response to the recent Web Forms / MVC flamewars that have been happening across the internet. Although I fall into the MVC camp it was good to see the Microsoft VP of the Developer Division try to calm people down. I believe Scott was trying to explain that both technologies are valid approaches to web development and that choosing one over the other for a project is not a reason to engage flamewars.

I have seen a lot of trashing of MVC by Web Forms adherents lately.  Web Forms advocates arguments break down into two categories reasoned opinions and FUD.  Here are some of the reasoned arguments I have seen.

  • they are already comfortable with the Web Forms page lifecycle
  • they don’t want to lose their investments in server controls that they have purchased or developed

Here are some of the arguments that just seem like FUD to me.

  • Web Forms are better for larger projects
  • Web Forms are more productive

Developers that have a lot of experience with Web Forms and a large investment in doing development using the Web Forms model and aren’t interested in MVC should stick with Web Forms. These are valid reasons for sticking with mature technology that isn’t going away anytime soon.

The other arguments however fall into the FUD category. Having just deployed a good size site built on ASP.NET MVC it works just fine for large projects. My team was definitely more productive using MVC than we would have been using Web Forms. Developers who are looking for more control over what is output to the page and a more agile development style should learn more about MVC.

When it comes to debating the merits of Web Forms and MVC the MVC camp is just as guilty when it comes to the religious wars that technology debates seem to turn into. Those who have made the switch to MVC really can’t understand why someone would stick with Web Forms and the limitations they impose on the developer. MVC developers see the page lifecycle and server controls as limitation while Web Forms developers see them as benefits. So what is really going on is developers trying to protect their ego’s by denigrating the choices others have made. This is basically a variation of the Emacs versus vi text editor wars.

It was nice to see someone of Scott Guthrie’s status in the community telling everyone to use their heads and try and use reasoned arguments and not go around blowing your stack at people who happen to disagree with you.

Update: Ian Cooper has written up a fantastic MVC or Web Forms comparison following up on Scott Guthrie’s article. Ian Cooper does a really great job summing up the argument for MVC and where Microsoft web development practices are going.

Atwood Needs to RTFM on Git

22 Jan

I was listening to the stackoverflow podcast  this morning when Jeff Atwood went off on an uninformed rant about the way that  github.com works. Jeff was complaining about network graph for the stackoverflow fork of the wmd JavaScript Markdown editor.

Jeff’s complaints showed a fundamental misunderstanding of how distributed source control works. Joel tried to explain to Jeff that in a DVC system forking or cloning a repository doesn’t mean anything unless the fork sends a pull request to the master repository to include its changes. Unfortunately Jeff couldn’t get past the way that github displays project forks on the network graph. If Jeff had spent some time becoming familiar with git and the concepts behind DVC systems the whole conversation wouldn’t have taken place.

Usually Jeff explores a concept in minute detail which is one of the reasons his blog became so popular. In this instance though he perform his usual exploration of a subject and it really showed. I hope he takes some time to become more familiar with DVC systems as they are a real boon to modern software development.

LINQ Distinct Fix

21 Dec

I needed to use the LINQ Distinct operation on a list of objects today and I ran into the fact that Distinct doesn’t take a lambda expression. You have to create a class that inherits IEqualityComparer and implements both the Equals and GetHashCode methods. This seems like a real pain to me. Distinct should take a lambda expression like the rest of the LINQ operators.

I found a workaround by using GroupBy, First, and Select like so.

var distinct = collection
       .GroupBy(c => c.FilterProperty)
       .Select(c => c.First())

DataAnnotations Custom Validation

17 Nov

I am putting this here because it took me way to long to find this information today.

Reference Links for this information:
[custom-validation-attributes]
[msdn]

To create a custom DataAnnotations validation attribute inherit from ValidationAttribute and implement IsValid.

public class CustomAttributeName : ValidationAttribute
{
    public override bool IsValid(object value)
    {
        bool validFlag = false;
        // perform validation here
        if (validFlag)
            return true;
        else
            return false;
    }
}

In the Model Validation Meta class use the custom validation attribute like this.

[MetadataType(typeof(EntityMetadata))]
public partial class Entity
{
    public class EntityMetadata
    {
        [CustomAttributeName(ErrorMessage=" [Required] ")]
        public object FieldName { get; set; }
    }
}