Debugging short exercise

From WLCS
Revision as of 23:30, 2 February 2011 by Admin (talk | contribs) (Created page with "'''Objective''': Practice debugging techniques This program is supposed to break once the ball has been caught, but it doesn't work. Your job is to work out why, and then fix it...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Objective: Practice debugging techniques

This program is supposed to break once the ball has been caught, but it doesn't work. Your job is to work out why, and then fix it.

  1. Download media:Catch-debug-exercise.py and open it in Dr. Python
  2. Add print statements to trace program execution
     print "Trace: At start"
    
    1. Start of the program
    2. Once the game window has been created
    3. Inside of the main game update loop
    4. Inside of the if statement that checks if the ball has been caught
    5. End of program
  3. Run the program and stop it as soon as the buggy behavior has occurred.
  4. Analyse the console output (the debug 'trace').
    What would you expect to see if the program was running properly?
  5. Is the problem that the distance isn't being properly calculated?
    Add another print statement that prints it.
  6. Once you've worked out what the real problem is, fix it.
  7. Submit your code to school web locker