Home Segments Index Top Previous Next

274: Mainline

You might wonder why you would ever want to replace calorie-based instance variables by gram-based instance variables. One answer is to increase efficiency. Suppose, for example, that you discover, on program testing, that fast access to gram information is more important than fast access to calorie information. You might then decide to switch from calorie-based instance variables to gram-based instance variables for faster access.

Of course, in a small program, you could manage changes similar to the replacement of calorie-based instance variables by gram-based instance variables without the benefit of access methods. In large programs, such changes would be extremely difficult without the benefit of access methods.