O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Theory of Inheritance

So far this chapter has focused mainly on the practical details of using inheritance in ActionScript. But the theory of why and when to use inheritance runs much deeper than the technical implementation. Before we conclude, let's consider some basic theoretical principles, bearing in mind that a few pages is hardly enough room to do the topic justice. For a much more thorough consideration of inheritance theory, see "Using Inheritance Well" (http://archive.eiffel.com/doc/manuals/technology/oosc/inheritance-design/page.html), an online excerpt from Bertrand Meyer's illuminating work Object-Oriented Software Construction (Prentice Hall).

Why Inheritance?

Superficially, the obvious benefit of inheritance is code reuse. Inheritance lets us separate a core feature set from customized versions of that feature set. Code for the core is stored in a superclass while code for the customizations is kept neatly in a subclass. Furthermore, more than one subclass can extend the superclass, allowing multiple customized versions of a particular feature set to exist simultaneously. If the implementation of a feature in the superclass changes, all subclasses automatically inherit the change.

But inheritance also lets us express the architecture of an application in hierarchical terms that mirror the real world and the human psyche. For example, in the real world, we consider plants different from animals, but we categorize both as living things. We consider cars different from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required