31-debugging - CS 106A Handout#31 Debugging As soon as we...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Handout #31 CS 106A July 27, 2009 Debugging 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 purpose of section this week is twofold: to give you a sense of the philosophy of debugging and to teach you how to use some of the practical tools that make debugging easier. This handout basically covers what we were hoping you would get in section. The philosophy of debugging With method and logic one can accomplish anything. — Agatha Christie, Poirot Investigates, 1924 Debugging is one of the most creative and intellectually challenging aspects of programming. It can also be one of the most frustrating. To a large extent, the problems that people face debugging programs are not so much technical as they are psychological. To turn you into successful debuggers, I have to get you to think in a different way. There is no cookbook approach to debugging, although Nick Parlante’s rules in Figure 1 will probably help. What you need is insight, creativity, logic, and determination. If there is any single aspect of today’s lecture that I hope you take with you, it is the idea that the programming process leads you through a series of tasks and roles: Design Architect Coding Engineer Testing Vandal Debugging Detective These roles require you to adopt distinct strategies and goals, and it is often difficult to shift your perspective from one to another. Beyond understanding the multiplicity of roles, the main point of today is that, although debugging is extremely difficult, it can be done. It will at times take all of the skill and creativity at your disposal, but you can succeed if you are methodical and don’t give up on the task. I also strongly commend to your attention—not now when you’re studying for the midterm and not necessarily even this quarter, but sometime—that you read Robert Pirsig’s critically acclaimed novel Zen and the Art of Motorcycle Maintenance: An Inquiry into Values (Bantam, 1974), which stands as the best exposition of the art and psychology of debugging ever written. Figure 1. The Eleven Truths of Debugging 1. Intuition and hunches are great—you just have to test them out. When a hunch and a fact collide, the fact wins.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
– 2 – 2. Don’t look for complex explanations. Even the simplest omission or typo can lead to very weird behavior. Everyone is capable producing extremely simple and obvious errors from time to time. Look at code critically—don’t just sweep your eye over that series of simple statements assuming that they are too simple to be wrong. 3.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 13

31-debugging - CS 106A Handout#31 Debugging As soon as we...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online