Structural Design ◾ 161
simulated with composition. To illustrate an eective inheritance design,
we revisit the Icon example from the previous chapter, where the design
goal was to represent Icons and their movement in a computer game.
We expand the Icon type denition to include the data and functional-
ity needed to support movement. Icons can spin, slide, or hop, with the
restriction that any particular icon is capable of only one type of move-
ment. A spinner cannot hop, a hopper cannot slide, etc. Furthermore,
the type of movement associated with an Icon does not change. us,
a slider cannot spin, not now, not ever. We incorporate into our design
the ability to track what “type” of movement an Icon object exhibits.
Example 6.7 sho ...