Hey, Don't Dump. Debug!
May 01, 2009, 19:46 (3 Talkback[s])
(Other stories by Martin Streicher)
Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js
"Out of curiosity, I also ask other coders about debugging
techniques, and more often than not, I am surprised by the answer.
Believe it or not, the vast majority relies on liberal "print"
statements sprinkled throughout code. Of course, "print" takes many
forms--dump pertinent data structures, emit trace statements to
standard error, and log interim results in a separate file--and
there are cases where these methods are mandated. Still, it puzzles
me why more skilled developers do not use a debugger. Extensions to
PHP allow for interactive forensics; Perl running within mod_perl
supports debugging; and Ruby on Rails's Mongrel provides the
-debugger option to interrupt execution and drop to a debug
console. "In my Rails work, I use the debugger extensively. The
debugger combines the power of the Rails console and the
Interactive Ruby Debugger, irb, and peers into running code
responding to incoming requests. Better yet, I can yield to the
debugger console anywhere--in a controller, a view, a plug-in or
helper. Within the debugger, I can inspect the stack, variables,
the params hash, and more.