Csc 216/s08/high virtue

From Expertiza_Wiki
Revision as of 23:33, 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[1] 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. An example of a card for this program is given here: side 1 [2] and side 2 [3] . An object, such as a ball, that can be passed between students will be needed to represent a 'flag'.


How to Play

Choose a programmer to run and debug the program. Choose several students to represent the lines of code in the program. Each student is handed a card with code on one side and the comment explaining what that code is supposed to be doing on the other side. The students who represent the lines of code should keep the side of the card with the code on it towards themselves and only show the programmer the side with the comments. The students stand in the order the code is supposed to come in. They then wait for the programmer to run them. The programmer passes a parameter of the correct type to the program. Each line of code then executes on the parameter given. Based upon the comments that the programmer is allowed to see and the parameter that he or she passed, they should be able to deduce what the desired, correct output should be. If the lines of code execute and the end result is different from what the programmer computed then it is necessary for the programmer to debug the program. The programmer will start debug mode and hand a flag, which represents the break point, to the first line of code. The first line of code will execute, and the rest of the program waits. The programmer can the query what the current value of the variable is. If satisfied the programmer will step to the next line of code, modeled by the chosen programmer saying, "Pass the flag down to the next line." If not satisfied the programmer will ask the student to show him the code side of the card. The programmer will then make the necessary corrections and continue the debugging process.