Csc 216/s08/high virtue

From Expertiza_Wiki
Revision as of 20:53, 25 March 2008 by Jpcarter (talk | contribs)
Jump to navigation Jump to search

Interactive Debugging

This exercise illustrates stepping through a program line by line to debug it.

The Problem

A simple example program is given here but many more could be designed.

Participants and Props

This exercise will require members of the class to act as lines of codes and one to be the programmer/ debugger. Cards with code on one side and comments on the other should be prepared before class.

The Script

Pick one student to be the programmer. Pick other students to represent lines of code, as many students as cards. It would be helpful to display the entire program on a screen for the whole class to see.

The programmer should place a flag where they think the program's problems start, likely with the first line of code represented by a student. Model this by having the student lines of code pass a ball or flag. The programmer should be able to read the comments on the card but not the code which is on the back side of the card. The programmer can ask the student line of code for the current value of any variables of interest, in this example, x. If the value is not what is expected, the programmer will know to change this line of code. When satisfied with one line, the programmer should ask to step to the next line. The student line of code will then pass the ball/ flag to the next student line of code. Again, the programmer can ask for the current value of any variables. Continue stepping through the program and editing lines as you move along until the end is reached. The programmer will need to try several inputs to ensure all bugs are removed.