Home Segments Top Top Previous Next

322: Mainline

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

For example, in Segment 316, a minutes instance variable was declared in the Attraction class, whereas an hours instance variable could have been declared. The right choice depends on whether you are more likely to be interested in minutes or in hours.