Should debug code be left in place, always, or added only when debugging and removed when the bug has been found?

Posted by gablin on Programmers See other posts from Programmers or by gablin
Published on 2011-01-02T22:34:24Z Indexed on 2011/01/02 22:57 UTC
Read the original article Hit count: 163

Filed under:

I, for one, only add debug code (such as print statements) when I'm trying to locate a bug. And once I've found it, I remove the debug code (and add a test case which specifically tests for that bug). I feel that it's cluttering the real code and therefore has no place there unless I'm debugging.

How do you do it? Do you leave the debug code in place, or remove it when obsolete (which may be difficult to judge when that is)?

© Programmers or respective owner

Related posts about debugging