Debugging by Thinking: A Multidisciplinary Approach (HP Technologies)

9.11 Assert assumptions

9.11.1 Basic tactic

Insert assertions into the program source.

9.11.2 Purpose

Make the assumptions of the code explicit.

9.11.3 Questions answered

The questions answered depend on the assertion used. Common assertions answer these questions:

9.11.4 Potential problems

9.11.5 Refined tactics

Make assertions preprocessor macros instead of procedures so they can be eliminated by redefining the macro.

9.11.6 Related tactics

Distinguish between fatal and nonfatal assumptions that are being violated. Report the nonfatal ones, but continue processing, possibly after remedying the problem.

9.11.7 Choosing tactics

Do a complete test run, with all assertions active, at least once before the program is put into production.

Категории