Code Exercises..
November 26th, 2003 by HenA while ago, Steve and I were talking about getting rusty codewise, and losing sight of the zone. That elusive place where the code flows from your mind and all is the nirvana it should be.
We got to talking about the idea that the reason we had lost it was due to a lack of exercise. We were unfit coders. Taking the analogy further, we needed to exercise.
Coming up with the exercises proved difficult. I liked things like Norbert which has very solid requirements, but Steve’s after more of a challenge. I also realised that I had been influenced by Dave Thomas’ Katas to a certain extent, though I feel as though the Katas are a bit too imaginary and I like to get something out of the exercise.
Think of it as the difference between chopping wood or punching a boxing bag. On the wood approach I end up with a nice lump of wood [which is nice if I own a fire, bad if I have to explain why my wife’s favourite tree is now toothpicks]. Punching a boxing bag merely exercises me. I like to be paid twice for one piece of work.
Anyway, all this happened a while back and I’ve no clue if I blogged on it. Steve and I lined up a monthly plan in which we would exercise for 3 weeks on the same thing, then spend the last week discussing. We leapt bravely into the world of OpenGL to draw a 3d witch on a broomstick. I managed a 2d one in an afternoon or so’s work [OpenGL is uggggllly], but attempts at 3d just created inside out terrors. I’m not sure where Steve got, we never finished.
Still, the last few days I’ve been partaking in another form of exercise. Unit Tests for code I don’t know much about. Most specifically, Jakarta Commons IO, a component I’ve been involved in from the beginning despite not being the original coder of a lot of the code, just trying to organise it into a release [2 years and counting]. So for the last four days or so, I’ve settled down and worked on basic unit tests at the end of the day. Nice exercising. I feel nicely warmed up and my mind has gone through the kata that is the foundation of the zone. Tonight was EndianUtils. Last night was too. There’s a lot to test.
And the real winner? Despite this just being a warm-up kata, and despite it being something that isn’t that big a deal codewise, I found a nice big fat juicy bug
So the reason for this blog is to suggest that exercise is good for you. Write a unit test for someone else’s code today.
