Home Segments Index Top Previous Next

402: Mainline

To understand the advantage of working with constructors, readers, and writers, suppose that your program has a statement that reads the price of a particular trade, T27. If you work with readers, you need to make no change to that statement to accommodate the switch from a price-based structure definition to a total-cost–based structure definition:

... read_trade_price (T27) ... 

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

... T27.price ... 
  | 
  | 
  v 
... T27.total_cost / T27.number ... 

Thus, constructors, readers, and writers isolate you from the effects of your efficiency-motivated switch from a price-based structure definition to a total-cost–based structure definition.