







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Insights into debugging, a crucial skill for computer scientists and programmers. Debugging is not just about technical issues but also psychological ones. The roles involved in programming, including debugging as the detective role. It also introduces the 11 truths of debugging by nick parlante and explains how to use an online debugger like eclipse to find bugs in a program. Useful for university students, particularly those studying computer science or related fields.
Typology: Exercises
1 / 13
This page cannot be seen from the preview
Don't miss anything!








Thanks to Eric Roberts and Nick Parlante for portions of this handout.
As soon as we started programming, we found to our surprise that it wasn’t as easy to get programs right as we had thought. We had to discover debugging. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs. — Maurice Wilkes, 1949
The 11 Truths of Debugging
Figure 2. Buggy program intended to play a simplified form of roulette
import acm.program.; import acm.util.;
public class Roulette extends ConsoleProgram {
/** Amount of cash with which the player starts */ private static final int STARTING_MONEY = 100;
/** Amount wagered in each game */ private static final int WAGER_AMOUNT = 10;
/** Runs the program */ public void run() { giveInstructions(); playRoulette(); }
/**
Figure 2. Buggy program intended to play a simplified form of roulette (continued)
/*
/**
/* Private instance variables */
private RandomGenerator rgen = new RandomGenerator(); }
Stanford Debugger perspective when it suspends. Do you want to open this perspective
private boolean isWinningCategory(int outcome, String bet) { if (bet.equalsIgnoreCase("odd")) { return outcome % 2 == 1; } else if (bet.equalsIgnoreCase("even")) { return (outcome % 2 == 0 && outcome != 0); } else if (bet.equalsIgnoreCase("low")) { return (1 <= outcome && outcome <= 18); } else if (bet.equalsIgnoreCase("high")) { return (19 <= outcome && outcome <= 36); } else { return (false); } }