Replace Superclass with Delegate

Symptom

A subclass that inherits from a parent that doesn't quite fit — overriding methods to no-ops, throwing 'unsupported', or using only some of the parent's surface (refused-bequest pattern).

Goal

Inheritance from a superclass that doesn't really fit (Liskov violations, awkward methods) becomes composition: the former subclass holds an instance and delegates explicitly.

Before the refactoring

class CategoryItem extends Scroll {
// uses some Scroll methods, refuses others
}

After the refactoring

class CategoryItem {
constructor() { this.scroll = new Scroll(); }
date() { return this.scroll.date(); }
}
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

Liskov violations: consumers can't trust subclass instances; polymorphism becomes unsafe; the inheritance relationship misleads readers about what the subclass actually is.

Tradeoff

Adds a forwarding method on the former subclass for every method the old superclass exposed — only worth it when the superclass relationship is misleading.

Relief

The misleading is-a relationship disappears; the former subclass can change its delegate's class without affecting its callers.

Trap

Replacing every inheritance with composition — including ones where the Liskov contract genuinely holds — pays forwarding-method ceremony for no real fit improvement.