There are many ways of doing debugging, using a debugger is one, but the simple one for the humble, lazy, programmer is to just add a bunch of print statements to your code.
i.e.
def foo(x): print 'Hey wow, we got to foo!', x ... print 'foo is returning:', bar return bar
Is there a proper name for this style of debugging?
Yes - it's known as printf() debugging, named after the ubiquitous C function: Used to describe debugging work done by inserting commands that output more or less carefully chosen status information at key points in the program flow, observing that information and deducing what's wrong based on that information.
The debugger statement invokes any available debugging functionality, such as setting a breakpoint. If no debugging functionality is available, this statement has no effect.
There are two types of debugging techniques: reactive debugging and preemptive debugging. Most debugging is reactive — a defect is reported in the application or an error occurs, and the developer tries to find the root cause of the error to fix it.
Yes - it's known as printf()
debugging, named after the ubiquitous C function:
Used to describe debugging work done by inserting commands that output more or less carefully chosen status information at key points in the program flow, observing that information and deducing what's wrong based on that information.
-- printf() debugging@everything2
Native users of other languages no doubt refer to it by the default print / log / or trace command available for their coding platform of choice, but i've heard the "printf()" name used to refere to this technique in many languages other than C. Perhaps this is due to its history: while BASIC and FORTRAN had basic but serviceable PRINT
commands, C generally required a bit more work to format various data types: printf()
was (and often still is) by far the most convenient means to this end, providing many built-in formatting options. Its cousin, fprintf()
, takes another parameter, the stream to write to: this allowed a careful "debugger" to direct diagnostic information to stderr
(possibly itself redirected to a log file) while leaving the output of the program uncorrupted.
Although often looked down on by users of modern debugging software, printf() debugging continues to prove itself indispensable: the wildly popular FireBug tool for the Firefox web browser (and similar tools now available for other browsers) is built around a console window into which web page scripts can log errors or diagnostic messages containing formatted data.
I've heard it called Caveman Debugging
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With