Concept

Inheritance Tax

Definition

The inheritance tax is the term The Pragmatic Programmer uses for the often-overlooked cost of relying heavily on class inheritance. When a child class extends a parent, it inherits not only useful behavior but a tight, permanent dependency on the parent's internal structure.

That dependency is the tax. It is invisible at first and grows as the class hierarchy deepens, eventually making the code rigid and surprising to change.

Why it matters

How it works

The Pragmatic Programmer authors observe that inheritance is frequently used for code reuse, but that is the weakest reason to use it. Reusing a parent's methods drags in its whole interface and binds the child to implementation details it never asked for.

Their recommended alternatives keep the benefits without the tax. Interfaces and protocols express what a type can do without dictating how. Delegation and composition let an object hold a collaborator and forward to it, so behavior is shared by reference rather than by ancestry. Mixins and traits add capabilities without forcing a single rigid hierarchy. Inheritance still has a place for genuine is-a relationships, but it should be a considered choice, not a reflex.

Where it goes next

Continue exploring

Tags