March 11, 2011

...Learn TDD with Codemanship

Software Craftsmanship Code Lab

TDD slows you down in the short term.

You can make your code too clean.

Focusing on craftsmanship makes you lose sight of customer needs.

etc etc etc.

All hearsay, and so far no evidence to support some of the claims made about clean code and craftsmanship. Conversely, we lack hard data to argue the reverse.

Starting at Software Craftsmanship 2011, I'll be running an international Code Lab, where through a series of experiments we may hope to get some real data to go with the anecdotes, and maybe a few surprises along the way.

The Code Lab track on May 26th will feature three experiments designed to answer the question "Is Test-driven Development slower in the short term?"

The experiments are still taking shape, but here's a sneak preview:

Download this skeleton Eclipse Java project for the Roman Numerals kata.

You'll see that it has the beginnings of a RomanNumeralConverter class, and about 30 JUnit acceptance tests in seperate folders. The requirement is to convert any number from 1 to 4999 into roman numerals.

Get a stopwatch (or clock) and time yourself doing the kata twice, several days apart (just so it's not fresh in your mind the second time you do it.)

Do it once practicing rigorous TDD. Then, a few days later, do it without any unit testing at all.

When you think you're done, run the acceptance tests. Don't stop the clock until all the acceptance tests pass. DO NOT RUN THE ACCEPTANCE TESTS UNTIL YOU THINK YOU ARE FINISHED.

If any acceptance tests fail, fix them all, then - only when you think you have fixed all the bugs - run them again. (In the live experiment, you will only get access to the acceptance tests when you deply your "finished" code. And there will be a built-in delay before you get feedback, to simulate the cost of feedback from an acceptance testing phase.)

I've done it twice, and finished quicker doing TDD both times.

If you're new to TDD (or just crap at it), we'll take that into account on the day by calibrating your results with the outcome of a short TDD exercise done beforehand, to give you you "TDD handicap".

Also, while I'm about it, I'm seeking a couple of volunteers to organise the Code Lab with me. Drop me a line if you're interested. The intention is to build up material for a Code Lab web site and maybe a paper publication, so you'll get full credit for your contributions. (You'll need to have registered for SC2011, obviously.)

Posted 7 years, 1 month ago on March 11, 2011