Fear, Courage and Unit Testing

At NDC I was fortunate to take part in a session of Cyber Dojo, run by Jon Jagger and Olve Maudal. You can have a taste at it online, but it’s better experienced with a guide. The attendees pair up, select a kata and a programming language and start adding features and tests. Every 5 minutes you switch pair. I was very lucky to pair with Michael Feathers, Jon Skeet, Corey Haines, Jim Shore and others in this session. But this post is not about name-dropping.

One thing to note is that programming was not done in an IDE. A browser-based editor for coding let you type in code, and then a single button would run the tests, and you get the result of the last run instantly.There are many things you can learn from this session (including how fast Jon Skeet could spread Linq within the different pairs ).

I want to concentrate on two feelings I experienced. Let’s start with…

Confidence

Working without a full IDE (Visual Studio or equivalent) robs you of signals you’re accustomed to. Without squiggly red lines, warning about syntax errors, I found my self relying on the “run test” button. It was no longer just running the tests – it told me that my code also compiled, and it’s ok to continue typing. The more I added code, I used the button more – just to get feedback on the current state of my code. This feedback gave me the confidence to continue.

It makes sense – with less information, you take small steps, and try to get as much feedback as you can before proceeding. It’s like wandering blindly in a labyrinth – you feel your way slowly, try to get as much tactile data with your hands.

And on to anxiety. Even borderline…

Hysteria

In the last session, before the bell rung, I wandered a bit. My code wouldn’t compile, and so I wanted to get back to a safe point where all my tests ran. My automatic reaction was to press CTRL-Z to undo the last changes. And then panic struck: This isn’t a real IDE. No undo for you. I actually felt real anxiety! I barely worked from memory to make the tests pass in the last second, feeling the pressure of looming failure.

So what have I learned?

It’s a great experience, everyone should try it.

Use the best IDEs you can. Even small features make you more productive.

You can’t code without confidence. Unit tests give you confidence and eliminate fear.