Home Segments Index Top Previous Next

256: Mainline

The look-it-up principle: A program should look up a frequently needed answer, rather than computing that answer, whenever practicable.

Recall, for example, that a radius member variable was declared in one version of the cylinder class definition; a diameter member variable was declared in another. The right choice depends on whether cylinder-conscious functions are more likely to be interested in radii or diameters.