Chapter 11 Debugging Definition Debugging is the process
Chapter 11: Debugging
Definition Debugging is the process of identifying and removing errors from programs.
“It’s not the computer. Maybe It’s you. “
Overview • Purpose of chapter is to examine basic strategies for fixing bugs. • The term debugging attributed to Admiral Grace Hopper in the 1940 s. While working on a Mark II Computer at Harvard, her associates discovered a moth stuck in the computer and thereby impeding operation, whereupon she remarked that they were "debugging" the system. • Typical types of bugs include variables not initialized, typos, non-existent array elements, etc.
Tip 1 Take a break This is a serious strategy, and scientifically based.
Tip 2 Get someone else involved Not just for a new set of eyes, but you should explain the program to them step by step. Programming buddies. What do you look for in a coding buddy? Should you aim to be the one with the least knowledge?
Tip 3 Simplify What are some of the ways that you simplify? • Incremental development to break up in manageable pieces. • Comment out. Note that having OOP can help because it allows easier isolation. • New sketch with just one of the classes. You’ll have less bells and whistles to work with
Tip 4 println() • You have been using this from the start. The text appears in the console. It prints while the program is executing. • Remember that you can concatenate or join text and variables. println("x: " + xpos) • print. Array() is also good because it will nicely format array contents and show the values along with index.
Tip 5 Debugging tool • A new feature in version 3. It can be turned on from toolbar or from menu. • You can pause program by specifying a break point. • Then you can continue or go step by step.
- Slides: 9