Fragile base class problem (source code)

= Fragile base class problem

A subclass may depend on its superclass's internal calls to overridable <object methods>. A base implementation change that preserves the base abstraction can then change subclass behavior. For example, a set subclass may count insertion attempts by overriding insertion. If a revised deletion operation rebuilds the set by dynamically dispatched clear and insert calls, it unexpectedly resets and increases that counter. <Object composition> can isolate the counting wrapper from the component's internal dispatch, provided only wrapper operations can mutate the owned component.