Tuesday, May 10, 2011

Remove those pesky source control bindings

So you took the plunge. You decided to migrate your source code away from Team Foundation Server into Git, Bazaar or Mercurial. You either started from fresh or you actually converted all your history.
Anyway, life is good. You open your new repository and open a Visual Studio solution, only to be confronted with this:


Visual Studio embeds source control bindings in your solution and project files. Those have to be removed so that will you no longer see this message. You could open each solution and select ‘yes’ to remove the bindings.
However, because I had a large number of solutions I didn’t want to this manually. So, I wrote a small Powershell script that automatically removes all those bindings in a given directory structure.
My small way of saying thanks to the Git community. Patches are welcomed through the usual Github channels.

Friday, May 6, 2011

It’s shit like this, developers

This week I was changing some contact details for a large company I’m dealing with when I encountered this gem of user interface design:


Here I was trying to enter my new zip code. When clicking ‘confirm’ the website informed me that this was an invalid zip code. The error message (in Dutch) says:

The zip code must contain 4 digits and two characters.

Hey, my zip code does have 4 digits and two characters. Why is this not being accepted? Well, because of the space between the digits and the characters.
Every time I see this kind of behaviour, I’m thinking of the Robustness principle.

Be conservative in what you send; be liberal in what you accept.

The programmer who created this probably just used a regular expression (something like \d{4}[A-Za-z]{2}) without considering the fact that people often write zip codes with a space. You know, like they do on regular letters.

The programmer had several options:
  • Create two input boxes (one for the digits, one for the characters) so I had visual feedback that they expected me to separate the digits and the characters. 
  • Write some client side scripting that disregarded any spaces I might enter. 
  • Actually try to parse my input before throwing their hands in the air and crying: “I give up! Will those users never learn!”. 
How much effort would it have been if the validation code first had stripped any whitespace from my input and then tried the regular expression method? It would have worked fine and I wouldn’t have been bothered with this break in my workflow.

So, next time you write some validation code (for dates, names, zip codes, whatever), think of the user and try to do your best to parse the input of the user before giving up.

(One of the reasons I like Remember The Milk so much is because they support a large number of input formats).