a little madness

A man needs a little madness, or else he never dares cut the rope and be free -Nikos Kazantzakis

Zutubi

Archive for April, 2007

Testing Is … A Worthy Challenge

One of the reasons I love programming is that I enjoy the challenge of problem solving. On the flip side, nothing is more boring than repetitive, mind-numbing tasks. The great thing is that when something in my job becomes repetitive, that is a problem in itself that can be solved by programming. Meta.

Good developers don’t write the same five lines over and over, we abstract into a function. We abstract groups of functions (or objects) into libraries, and libraries into frameworks. Done right, we both take the tedium out of the job and enjoy the challenge of doing so. Then we get to enjoy the challenge of focusing on the real problems. If you like a challenge (and who doesn’t?), then you’re in the right place.

So why is it, then, that many developers avoid testing because they see it as a mind-numbing and repetitive activity? It is almost as if developers believe testing is an unskilled task that is doomed to be menial. In actual fact, testing takes many of the same skills as developing features. If you find it repetitive, ask yourself why and challenge yourself to do something about it. It is a perfect opportunity to put your problem solving skills to work.

Testing Is … Better Than Debugging

The Testivus “manifestivus” says Testing Beats Debugging:

We believe that time invested writing and running tests is better than time spent debugging.

The Google Testing Blog is headlined by a graphic that states:

Debugging Sucks. Testing Rocks.

I agree wholeheartedly. Debugging is a fact of development life1. It even has its own rewards, such as the sense of achievement when you find and squish a particularly nasty bug. Simply put, however, debugging is a massive waste of time2. Any time spent debugging could otherwise have been spent actually writing code, or otherwise being productive. Ergo, anything that helps to reduce the amount of time spent debugging is a Good Thing.

Testing reduces time spent debugging in various ways:

  • Well-crafted assertions in your tests will narrow bugs down right to the source. Operating at the unit test level in particular is more precise than manual testing.
  • Automated tests catch problems early in the development cycle, when they are easier to debug. It is well known that the earlier a problem is found, the easier it is to fix.
  • Regression tests catch problems that have been debugged before, so you don’t need to debug them again. This is particularly powerful in complex areas where bugs pop up frequently.

So, if you embrace testing, you can spend less time debugging and more time doing what you enjoy: writing great code ;).


1 At least until we start writing perfect code…
2 Note that is debugging, not using a debugger: they are quite different.