Standards-13
Tracing


Major errors

Do not omit required traces [7%]

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.

Trace prints must be controllable [6 points each, 5% max]

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(traceLevel > 0)
  {
    ...
  }
where traceLevel is an integer global variable that indicates the level of tracing, and 0 might be replaced by 1, 2, etc.

Show sensible information in a trace print [4-8 points per bad trace, 6% max]

Every trace print should show:

  1. The name of the function that does the trace;
  2. An indication of where the trace occurs;
  3. Suitable values to make the trace useful;
  4. An indication of what the values being shown represent, if any values are shown;
  5. Values being shown, if any;
  6. A newline, if appropriate, so that trace prints are not run together on the same line.

For example, a trace print that occurs at the beginning of a loop body in function getCompatibility might look like the following.

  if(traceLevel > 0)
  {
    printf("getCompatibility: [top of loop] working on k = %i\n", k);
  }

A 6-point error is one where the trace tells a lie about which function does the trace, where the function is or what a value represents. If you copy a trace from one place to another, make sure to edit what it says.



Minor errors

Do not comment out traces [4 points each, 1% max]

A trace print should be left in the program but made controllable. It should not be commented out.

Keep trace code short [4 points each, 2% max]

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.

Write traces to standard output [6 points]

For this course, write all trace prints to the standard output. If you write the trace to a file, I have to find it.

(Larger pieces of software often have provisions to write traces to files, but we are not doing that in this course.)