Sie sind auf Seite 1von 12

Computer and Information Technology for (HKCEE) Module A2

7.1Type of Program Errors


7.2 Program Tracing
7.3 Debugging Tools
7.4 Program Testing
Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.1 Type of Program Errors


Types of program errors
syntax errors
logic errors
run-time errors

© Longman Hong Kong Education Page2


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.1 Type of Program Errors


Syntax errors
errors in the structure of the program
compiler identifies the line numbers in which the
errors are located
can be solved by fixing and recompiling the
program several times
examples
undefined symbol i
missing;
integer mistyped as interger

© Longman Hong Kong Education Page3


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.1 Type of Program Errors


Runtime errors
errors encountered during execution of the
program
can be avoided by better program logic
examples
divide by zero error

© Longman Hong Kong Education Page4


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.2 Program Tracing


Tracing
track the operation of the program
watch how the variables change at different
stages of the program
help us understand the operation of an unknown
algorithm
Dry run
tracing done manually using pencil and paper

© Longman Hong Kong Education Page5


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.2 Program Tracing


Echo checking
insert output statements at strategic locations in
the program
get the intermediate values at each stage of
calculation or logic
advantage
conceptually simple
disadvantage
inefficient with regards to effective use of throughput

© Longman Hong Kong Education Page6


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.3 Debugging Tools


Common debugging features
setting breakpoints
stepping through the program
watching variables

© Longman Hong Kong Education Page7


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.3 Debugging Tools


Breakpoint
a line in the program at which we can set the
program to pause

breakpoint

© Longman Hong Kong Education Page8


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.3 Debugging Tools


Step into
step through instructions in the program
line-by-line
enter each encountered function call
Step over
step through instructions in the program
line-by-line
do not enter encountered function call
Watches
display the expressions in the program

© Longman Hong Kong Education Page9


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.4 Program Testing


Program testing
discover possible logic errors
tested by several sets of typical data
tested for abnormal data
negative values
out-of-range data
zeros
file opening error

© Longman Hong Kong Education Page10


Computer and Information
Technology for (HKCEE)
Module A2: Part B

7.4 Program Testing


Data validation
check data to see if they fit the assumption of the
program
Test plan
contain many test cases to test a program

© Longman Hong Kong Education Page11


Computer and Information Technology for (HKCEE) Module A2

END

Das könnte Ihnen auch gefallen