Little victories in programming with test-driven development

Those of you bored enough to read my blog regularly probably know that I coach 17-year-old girls in junior Olympic volleyball. In teaching my kids to improve upon their skills, I frequently tell them not to worry so much about the big picture when I want them to concentrate on the smaller things.

For example, to pass accurately on serve receive, you have to be behind the ball and squared to your target, pushing out with your legs, not swinging your arms. If a kid is diving around because they aren't moving to the ball, I set the goal to simply meet the ball, body firmly in front of it. If they can do that consistently, I'm not as concerned about them squaring to target, using their legs or whatever. It's a little victory toward the bigger goal.

Using test-driven development is a lot like that. You write all of these tests, maybe hundreds, and start to write code that passes the tests. There's no way in hell you'll pass them all the first time you run the tests (if you do, you're doing it wrong). But every test you pass is a little victory toward the bigger goal.

If you can concentrate on said victories, I think you can get a lot more enjoyment out of even the most mundane programming tasks. That's why I like TDD.

No Comments