O'Reilly logo

Agile Principles, Patterns, and Practices in C# by Robert C. Martin, Micah Martin

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

22. TEMPLATE METHOD and STRATEGY: Inheritance versus Delegation

image

© Jennifer M. Kohnke

The best strategy in life is diligence.

—Chinese proverb

In the early 1990s—in the early days of OO—we were all quite taken with the notion of inheritance. The implications of the relationship were profound. With inheritance, we could program by difference! That is, given a class that did something almost useful to us, we could create a subclass and change only the bits we didn’t like. We could reuse code simply by inheriting it! We could establish whole taxonomies of software structures, each level of which reused code from the levels above. It was a brave ...

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