[Tutor] print stack traces not caused by errors
Alan Gauld
alan.gauld at btinternet.com
Wed Jan 5 10:21:06 CET 2011
"Corey Richardson" <kb1pkl at aim.com> wrote
>> And of course print statements work too within the console
>> window.
>
> I've done almost all my debugging via print statements at crucial
> points. It's a good way to go, IMO.
It's a good way to go for short simple programs.
The big disadvantage is that the larger the program the more
prints you need to insert. Then you have to take them all out
again before shipping the final version. That's a lot of potentially
error prone work. Plus a lot of print statements can slow code
down which can be important where interaction with external
systems/networks is important. A debugger usually has a
much less invasive impact performance wise.
Using a proper debugger allows you to dynamically "print"
anything at any point in your program without leaving a
footprint in your code when you are finished.
Both print and debug have their place, my personal preference
is a few print statements but if it gets to more than 3 or 4 then
I move to the debugger. And a decent GUI debugger is *much*
easier to use than pdg/gdb etc
And of course a critical visual review of the code is the first
step of all!
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list