Delegation

The idea of delegation is simple. When you create a new object, instead of naming a class, you can name a delegate. A delegate is simply another object. By naming a delegate, you explicitly say that any messages I do not understand will be passed along to my delegate. Thus, the delegate is the respository of behavior, just like a class, and this behavior can be overridden, just as we do with inheritance, but a delegate is just another object. Thus, we have replaced both classes and inheritance with the one simple idea of delegation.

[audio] [real] Text to accompany slide11, in Chapter 20 of An Introduction to Object-Oriented Programming