< previous page page_80 next page >

Page 80
0080-01.gif
Figure 2-6
Debugging Procedure
SOFTWARE ENGINEERING TIP
Understanding Before Changing
When you are in the middle of getting a program to run and you come across an error, it's tempting to start changing parts of the program to try to make it work. Don't! You'll nearly always make things worse. It's essential that you understand what is causing the error and that you carefully think through the solution. The only thing you should try is running the program with different input data to determine the pattern of the unexpected behavior.
There is no magic trickinserting an extra semicolon or right brace, for examplethat can automatically fix a program. If the compiler tells you that a semicolon or a right brace is missing, you have to examine the program in light of the syntax rules and determine precisely what the problem is. Perhaps you accidentally typed a colon instead of a semicolon. Or maybe there's an extra left brace.
A good rule of thumb is: If the source of a problem isn't immediately obvious, leave the computer and go somewhere where you can quietly look over a printed copy of the

(text box continues on next page)

 
< previous page page_80 next page >