Home Segments Index Top Previous Next

200: Mainline

Suppose, for example, that your program contains a statement that reads the diameter of a particular tank_car, t. If you work with readers, you need to make no change to that statement to accommodate the switch from a radius-based class definition to a diameter-based class definition:

... t.read_diameter ( ) ... 

On the other hand, if you do not work with the member variables in tank_car objects using constructors, readers, and writers only, you have to go through your entire program, modifying myriad statements:

... t.radius ... --> ... .5 * t.diameter ... 

Thus, constructors, readers, and writers isolate you from the effects of your efficiency-motivated switch from a radius-based class definition to a diameter-based class definition.