Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This section begins where the Bicycle example in Chapter 6, Acquiring Behavior Through Inheritance, ended. If that code is no longer in the forefront of your mind, it’s worth flipping back to the end of Chapter 6 and refreshing your memory. This section takes that example and moves it through several refactorings, gradually replacing inheritance with composition.
The Bicycle class is currently an abstract superclass in an inheritance hierarchy and you’d like to convert it to use composition. The first step is to ignore the existing code and think about how a bicycle should be composed.