Maintenance and Extensibility Planning | 57
In turn,RecordVideoinheritsfromRecordMedia. At this point, we’re right back to the
class to which theMedia class first delegated,RecordMedia.
Using composition without inheritance is difficult to imagine in most practical appli-
cations. Thus, instead of focusing on the relative advantages of each, for now con-
sider composition and inheritance a team. In Chapter 11, we again consider this
issue of favoring composition over inheritance in the context of using composition
with design patterns.
Maintenance and Extensibility Planning
A number of years ago, we built a web site designed for change. At the time, no
thought was given to design patterns, but instead we knew that the site would
change based on experience, and were acutely aware of making sure that the site was
set up for accepting change without having to redo it.
This was a case where the plan worked too well. The site is easy to update and as a
result, we really haven’t bothered to take the time to rework the site to incorporate
new concepts. It’s starting to look a little old-fashioned, and we’d like to upgrade the
version of Flash so that we can optimize video and all the new features in Flash CS3
Figure 1-8. Relationships of composition, inheritance, and instantiation
Mp3.as
{}
Media.as
{}
VideoFlash.as
{}
PlayVideo.as
{}
PlayMedia.as
{}
PlayAudio.as
{}
RecordVideo.as
{}
RecordMedia.as
{}
RecordAudio.as
{}
delegates
Instantiates
Inherits