[Techtalk] Ruby/Perl Tutorials

Monique Y. Mudama monique at bounceswoosh.org
Fri Apr 16 15:14:06 UTC 2010


On Fri, Apr 16 at 15:27, John.Sturdy penned:
> Definitely.  An interesting variant of it that I picked up years ago
> was "Never remove debugging print statements when you don't need
> them any more, just comment them out."  This is because they tell
> other people looking at the code what variables were of interest for
> debugging it, and what the issues in developing the code were.
> Obviously sometimes there are just too many and they have to be
> removed as clutter, but leaving some in can be a very informative
> form of commenting.

Yes, but if at all possible, it's even better if you can use a
conditional to turn debugging output on and off as needed.  That's
what make log4j and all of the similar logging systems so great - you
can keep everything and decide what you need to see at runtime.
(Performance issues aside, etc etc ...)

The conditionals approach also guards against accidentally forgetting
to remove / comment out that *one* line that then shows up in your
production environment.

I worked in a system that used a lot of T-SQL stored procedures, and I
would often add an @debug parameter that defaulted to 0.  That way I
could pepper the code with output, but it was hidden unless I
specifically called the proc with @debug = 1.  Super handy.  It
doesn't sound like much of a difference, but in a situation where the
production environment is locked down and you only have certain
permissions, it can save a lot of time.

Granted, this approach may be overkill for some situations ...

-- 
monique


More information about the Techtalk mailing list