How to Find Bugs in Four Easy Steps

by Ville Laurikari on Monday, August 3, 2009

Going over some code with Mr. Duck.

The Rubber Duck method of debugging goes like this:

  1. Beg, borrow, steal, buy, fabricate or otherwise obtain a rubber duck (bathtub variety).
  2. Place rubber duck on desk and inform it you are just going to go over some code with it, if that’s all right.
  3. Explain to the duck what you code is supposed to do, and then go into detail and explain things line by line.
  4. At some point you will tell the duck what you are doing next and then realise that that is not in fact what you are actually doing. The duck will sit there serenely, happy in the knowledge that it has helped you on your way.

This works amazingly well. There’s a whole section in the book The Pragmatic Programmer about it. Also, The Practice of Programming describes the close relative, the Teddy Bear method of Filtering Bug Reports:

One university computer center kept a teddy bear near the help desk. Students with mysterious bugs were required to explain them to the bear before they could speak to a human counsellor.

You should definitely get these books if you’re interested in reading about insights similar to the rubber duck. These books are full of great stuff, but especially The Pragmatic Programmer does an awesome job of explaining things such as the broken window theory, defensive programming, and the DRY principle.

The Pragmatic ProgrammerThe Pragmatic Programmer

If you liked this, click here to receive new posts in a reader.
You should also follow me on Twitter here.

Comments on this entry are closed.

Additional comments powered by BackType

Previous post:

Next post: