Trace prints must be controllable [Trace control: 1-5 points]
A trace print
is a statement or sequence of
statements that are present for debugging.
Such prints can be left in the program, but it
must be easy to turn them on or off. Write
if(trace > 0) { ... }where trace is an integer global variable that indicates the level of tracing, and 0 might be replaced by 1, 2, etc. |
A trace print should be left in the program but made controllable. It should not be commented out. |
For this class, write all trace prints to the standard output. (Larger programs often have provisions to write traces to files.) |
Every trace print should show:
if(trace > 0) { printf("getCompatibility: [top of loop] working on k = %i\n", k); } |
If the assignment requires traces, then you must include them. Don't add them after everything is working! The point of tracing is to help get things working. |
Do not clutter a function definition with a long sequence of lines that are concerned with tracing. Instead, create a function and call the function to shorten it. Any sequence of more than 3 lines (excluding the controlling if-statements and its associated braces) is too long. Do not write a loop in a trace-print. Use a function instead. |