CASE STUDY
190
Here is a sample output from running the program:
Here is another sample run:
4.7 Testing and Debugging
In Chapter 1, we discussed the problem-solving and implementation phases of computer
programming. Testing is an integral part of both phases. Testing in the problem-solving
phase occurs after the solution is developed but before it is implemented. In the imple-
mentation phase, we test after the algorithm is translated into code, and again after the
code has compiled successfully. The compilation itself constitutes another stage of test-
ing that is performed automatically.
Testing Strategies
When an individual programmer is designing and implementing an application, he or she can
find many software errors with pencil and paper.Desk checkingthe design solution is a very
common method of manually verifying a design or code. The programmer writes
down essential data (variables, input values, parameters of methods, and so on) and
walks through the design, manually simulating the actions of the computer and
recording changes in the data on paper. Portions of the design or code that are
complex or that are a source of concern should be double-checked.
Desk checking Tracing an
execution of a design or code
on paper
T
E
A
M
F
L
Y
Team-Fly®