Programming and Problem Solving with Java

(やまだぃちぅ) #1
4.7 Testing and Debugging | 195

through the algorithm and the code, tracing the execution of the application, and devel-
oping a thorough test strategy, you should be able to avoid, or at least quickly locate, se-
mantic errors in your code.
Figure 4.9 illustrates the testing process we’ve been discussing. It shows where syn-
tax and semantic errors occur and in which phase they can be corrected.

Testing and Debugging Hints

1.Java has three pairs of operators that are similar in appearance but different
in effect: ==and =,&&and &, and ||and |. Double-check all of your logical
expressions to make sure you’re using the “equals-equals,” “and-and,” and
“or-or” operators. Then check them again to confirm that you didn’t double
type the <or >operators.
2.If you use extra parentheses for clarity, make sure that the opening and clos-
ing parentheses match up. To verify that parentheses are properly paired,

Phase Result Testing Technique Type of Error

Problem solving Algorithm Alwalk-througorithmgh Semantic

Implementation Coded program TrCode walk-throuace gh, SSyemantintaxc

Compilation Object program Compiler-error messagenerateges d Syntax

Execution Output Implementest plan t TypoAlgorithm semantigraphical semantic c

Figure 4.9 Testing Process

Free download pdf