Home Segments Index Top Previous Next

222: Mainline

Maintaining multiple copies of member variables and member functions makes software development and maintenance difficult as you try to correct bugs, to add features, to improve performance, and to change behavior. Adding multiple programmers and multiple years to the mix turns mere difficulty into certain failure.

Of course, with just two new member variables and one new member function about which to worry, you could cope. In a more complex example, every kind of container, from railroad car to cereal box, would have a percentage_loaded member variable, along with a variety of other member variables, capturing information dealing with such characteristics as durability and visual appeal. Similarly, every kind of railroad car would have not only a year_built member variable and an age member function, but also a variety of other member variables and member functions dealing with such characteristics as their weight, number, owner, and destination.