Csc 216/s08/high virtue: Difference between revisions
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
===Participants and Props=== | ===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 [http://pg-server.csc.ncsu.edu/mediawiki/index.php/Image:Side1.jpg] and side 2 [ | 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 [http://pg-server.csc.ncsu.edu/mediawiki/index.php/Image:Side1.jpg] and side 2 [http://pg-server.csc.ncsu.edu/mediawiki/index.php/Image:Side2.jpg] . | ||
Revision as of 21:48, 25 March 2008
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. An example of a card for this program is given here: side 1 [1] and side 2 [2] .
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.