C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Inheritance - a single-shot opportunity for specialization

Chapter 13: Elegant code in the new era: 13.2

Created: 3/6/2008
Last updated: 3/6/2008

Eric has another way of talking about the use of delegates instead of inheritance for specialization.

Indeed. Inheritance is a tremendously powerful tool for sharing implementation details and specializing behaviour. But the fact that you only get "one shot" at inheritance in a single-inheritance world means that you’ve got to take that shot carefully and make sure you're using that power to its best ability. What you’re describing [delegates] is an alternative approach to specialization which is much less "expensive" since it does not waste your inheritance shot on something not worth the power.