Chapter 9. Decorator Pattern

<feature><title>In This Chapter</title> </feature>

The Decorator pattern enables you to apply new behavior to an object at runtime. Traditionally, many developers learn to add behavior by using inheritance rather than composition. This means that if you want to add a move() method to an existing Widget class, you’d extend Widget to define a new MovableWidget class. Or, if you want to redefine the move() method of MovableWidget so that it moves only until its fuel is used up, you could extend MovableWidget to define FuelableMovableWidget.

However, inheritance has two major drawbacks in such cases: ...

Get Advanced ActionScript 3 with Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.