[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Delegation vs. Inheritance
There are certain similarities between delegation and inheritance, and in
fact inheritance can be implemented using delegation. However, delegation
can be more flexible than inheritance, in that an object being delegated
to can be replaced by some other object at runtime. The replacement object
could be another object of the same class as the original delegatee, or it
could even be an object of a different class. Using inheritance,
equivalent operations are either not possible or practical.
Changing the target of delegation in this way occurs at runtime and
affects individual instances, making it possible for different instances
of the same class to behave very differently. It is this that makes
delegation potentially more powerful than inheritance in the right
circumstances.
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson