philwilson.org

Debugging

27 July, 2017

I do not like debugging. I prefer good logging.

The log4j manual quotes Brian W. Kernighan and Rob Pike from their “truly excellent book” The Practice of Programming:

As personal choice, we tend not to use debuggers beyond getting a stack trace or the value of a variable or two. One reason is that it is easy to get lost in details of complicated data structures and control flow; we find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places.

Clicking over statements takes longer than scanning the output of judiciously-placed displays. It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient.

There are times when a debugger can be really helpful, but in my experience they are normally used as a fallback for a poorly documented system with an unclear flow of logic, or overly large methods with poor test coverage.

See other posts tagged with debugging logging programming and all posts made in July 2017.