Nick McKenna's Blog

Agile, Software, Technology
posts - 43, comments - 15, trackbacks - 24

Sunday, April 05, 2009

How Much TDD?

For the last couple of years I have been zealous in my TDD discipline. By zealous I mean that when I write "public" on a method, I write a test. I was fortunate enough to attend a session on Testing Patterns (see previous blog entry). I had a question for the speaker about how he would handle testing a particular simple method. In this case the method was something like AddNewJob(xxx). To my suprise the recommendation was that I should not bother unit testing it as it was too simple and I should leave it up to the testers to cover it off in their testing activities!

This was a real eye-opener for me, so now I am in a bit of a quandry. Lots of the code I right for mid-range applications is very similar to this method. The AddNewJob(xxx) method inserts data into a few related tables. My tests have historically queried the SQL tables to ensure that the insert was completed correctly. I had noticed a significant reduction in error rates following this approach.

As an experiment, I have recently ( a few weeks ago) stopped writing unit tests for all "public" methods and I am just writing tests for more complex methods. I have made a few observations as a result of this experiment:
  • I don't think my error rate has gone up
  • I do not believe that my coding speed has improved
  • I am writing almost no tests (most of my code is very simple - which is a good thing I suppose)
  • I don't feel virtuous any more
In the short-term then, I seem to have retained the benefits of TDD even though I am not doing it as much! I suspect in the long term that my "untested" code will suffer a little as I do not have automated tests around it. I think that this means I will not spot side-effects of code changes as early as I will on tested code.

I suspect that my retention of quality is a direct result of the extra coding discipline that TDD has instilled in me. I find my self being much more careful about parameter checking etc these days. I think that the longer I go without writing tests, the more lax I will become in my coding and my error rate will begin to creep up again.

So, the result of my experiment is pretty inconclusive (largely because I have not formally collected data) and I think I will retain to my more zealous approach, if for no other reason than it makes me feel more confident and more virtuous about my code!

posted @ Sunday, April 05, 2009 7:22 PM | Feedback (0) | Filed Under [ Agile ]

Alt.Net In The North

I am one of the organisers for the Alt.Net in the North Open Spaces event which will be held in Bradford, West Yorkshire on Saturday 18th April. Planning for the session will take place on Friday (17th April) evening. The event is limited to 50 attendees and is filling rapidly.

An Open Spaces event is a sort of anti-conference. Rather than advertise speakers and topics in advance, the speakers and topics are organised the night before based on the desires of the attendees. Anyone can present and anyone can attend any session.

The event is free to attend and is kindly being sponsored by Black Marble, Seed Software, Skills Matter and Agile Yorkshire.

I am really looking forward to the event and hearing from some leading industry figures as well as some great "from the trenches" stuff!

posted @ Sunday, April 05, 2009 7:09 PM | Feedback (0) | Filed Under [ Agile ]

Agile Yorkshire Crystal Clear

Just a reminder to everyone that Richard Fennel of Black Marble will be presenting on Crystal Clear at Agile Yorkshire on Wednesday 8th April 2009. This will be a beginner's introduction to the Crystal Clear Agile method.

Further details here.

posted @ Sunday, April 05, 2009 7:03 PM | Feedback (0) | Filed Under [ Agile ]

Powered by: