23
Refused Bequest
Symptom
A subclass inherits methods or fields it doesn't actually use — overriding to no-ops, throwing 'unsupported', or just ignoring the inheritance.
Goal
Sharing happens through composition (a delegate object) rather than forced inheritance.
Smellier version
class Animal { fly() {} swim() {} }
class Dog extends Animal {
fly() { throw new Error('no'); }
}Fresher versionclass Dog {
// composes a Mover delegate that knows it's a swimmer
}Savings
Each class has only what it needs; surprises in polymorphic use disappear.
Note
Liskov violations: callers can't trust subclass instances to honor the parent contract; polymorphism becomes a trap.