Pages

Tuesday, 22 December 2009

Muzzling an Angry Dog

I've been setting aside as much time as possible recently to read Michael Feather's Working Effectively with Legacy Code. A large amount of our code-base for one product is very much in this court and now, unfortunately, needs dealing with. Luckily, though, the more I refactor this type of code the more I realise how much I enjoy it.

I was explaining some of the governing principals to a colleague today...

  • "First you have to get your legacy code into a test harness, then you can safely alter it."
  • "OK."
  • "However, you'll need to alter it before you can do that."
  • "Huh?"

I have come to the conclusion that Working with Legacy code does not so much involved harnesses as muzzles. It is akin to Muzzling an Angry Dog. First, you have to sneak up to it, from behind, without making any noise or disturbing it's environment. Then, once the muzzle is safely on you can relax and poke it as much as you like. From now on, our estimates will have a 'Dog Muzzling' factor added to them.




[And, no, I do not condone taunting any dog, angry or otherwise.]

Tuesday, 8 December 2009

Annual Company Review

We have just had our annual Company Meeting today - accompanied by some stellar Italian food. Part of my presentation was to review our development achievements over the past 12 months. In December 2008 we were using Visual Studio 2005 and Visual Source Safe - and that was pretty much it. Today, just 12 months later we have implemented the following:

  • Visual Studio 2008 Developer + Database Editions
  • Team Foundation Server 2008
  • TFS Source Control
  • Continuous Integration Server
  • Nightly Builds
  • Fully automated build and deploy to test servers
  • Unit Tests (20% Code Coverage so far)
  • Code Reviews
  • 2 projects using Scrum
We now score 10 / 12 on the Joel Test.

Wow, what a difference a year makes!

Monday, 7 December 2009

Moq Setup Causes Compiler Error CA1506

I have been using Moq to help enable some unit tests and I've been getting intermittent build exceptions caused by the Code Analysis engine when calling the Setup method of my new mock object.

Example:

var mock = new Mock<IDoSomething>();

mock.Setup(x => x.DoSomething());

CA1506 is raised as a warning to Avoid excessive class coupling. This is, obviously, a little strange. Stranger still is that this warning results in a compilation error.

Anyway, it's a bug in Visual Studio. The workaround is just to remove this check from your Code Analysis (goto Project Properties | Code Analysis | Maintainability Rules and uncheck CA1506).