1.8 Testing and Debugging | 33
1.8 Testing and Debugging
Even the best-laid plans sometimes go awry. Along the way, we will offer tips on what to do when things
don’t work as expected. We will also offer advice on how to avoid problems (programming bugs) in the
first place.
Testing and Debugging Hints
1.Be sure to understand the problem before you start trying to solve it.
2.Note anything that is unclear and ask questions to clarify the problem.
3.Rewrite the problem statement in your own words.
4.Identify the objects required and their capabilities.
5.Use the problem-solving techniques discussed in this chapter to help develop your solution.
6.Keep in mind the actions that a computer can perform when developing solutions for it.
Summary
We think nothing of turning on a television and sitting down to watch it. Television is
simply a complex communication tool that we use easily. Today computers are
becoming as common as televisions—that is, just a normal part of our lives. Like tele-
visions, computers are based on complex principles but are designed for easy use.
Computers are dumb; they must be told what to do. A true computer error is
extremely rare (and usually crops up because of a component malfunction or an elec-
trical fault). Because we tell the computer what to do, most errors in computer-gener-
ated output are really human errors.
Computer programming is the process of developing a problem solution for a com-
puter to execute. It encompasses a problem-solving phase as well as an implementa-
tion phase. After analyzing a problem, we develop and test a general solution (an
algorithm). This general solution becomes a concrete solution—a program—when we
write it in a high-level programming language. A program coordinates the interactions
of a collection of objects that collaborate to solve the problem. Objects are an assem-
blage of data and operations that can be applied to those data. They are often