Page 6: Debugging Recap

Unit 3, Lab 1, Page 6

On this page, you will review what you’ve learned about debugging in Snap!.

Debugging is the art of identifying errors in computer programs and fixing them.

Tips

photo of Grace Hopper

Grace Hopper (1906-1992) was an United States Navy rear admiral and pioneer of computer programming. She is best known for her trailblazing contributions to computer programming, software development, and the design and implementation of programming languages.

60 Minutes: Grace Hopper

One early case of “debugging” was when an actual moth got stuck inside a computer Grace Hopper was working with in 1947. Here is a page from her notebook with the moth pasted in.

Photo of the first actual case of bug being found, at Mark II Aiken Relay Calculator, Harvard, 1947

Talk with Your Partner

  1. Which of these tips would have helped you debug one of your projects? Pick one and discuss your experience with your partner.
  2. Choose one of these tips that doesn’t make sense to you, and try to figure out why we included it.

Snap! Debugging and Organizing Tools

  • pause all places breaks in your code so you can step through the code at your own pace.
  • say for can give you information about the state of your program while it’s running.
  • Visible Stepping (Visible Stepping button with two footprints) lets you control how quickly Snap! steps through the blocks of your code.
  • Ways to show the values of variables and sprite attributes:

    • Clicking a reporter will show the value of a variable or sprite attribute.
    • Checking the box next to a variable in the palette (Variable with check-box checked) will also show the value of that variable or sprite attribute.
    • show variable lets you do the equivalent of checking the box for script variables, which aren’t in the palette.
  • Comments let you document your program.
  • The “Unused blocks…” option in the Snap! File menu will eliminate blocks you no longer need. This is often useful when you’ve loaded a library but you only need one or two blocks from the library.
  • The “clean up” option in the right-click (or control-click on a Mac) menu of the scripting area background will reposition scripts on the page so they don’t overlap.
  • AAP-1.A.2

    Snap! lets you use more than one word in the name of a block or variable. Some programmers try to save time by naming all their variables x, but if they forget and call a second variable x, this can lead to bugs. To make your programs easier to understand and debug, you can use meaningful names, such as horizontal position, instead.