You are previewing Code Complete, Second Edition.

Code Complete, Second Edition

Cover of Code Complete, Second Edition by Steve McConnell Published by Microsoft Press
O'Reilly logo

Guidelines for Initializing Variables

Guidelines for Initializing Variables

Improper data initialization is one of the most fertile sources of error in computer programming. Developing effective techniques for avoiding initialization problems can save a lot of debugging time.

The problems with improper initialization stem from a variable's containing an initial value that you do not expect it to contain. This can happen for any of several reasons:

  • The variable has never been assigned a value. Its value is whatever bits happened to be in its area of memory when the program started.


    For a testing approach based on data initialization and use patterns, see "Data-Flow Testing ...

The best content for your career. Discover unlimited learning on demand for around $1/day.