Collapse Hierarchy

Compare
Symptom
Human

A subclass that no longer differs meaningfully from its parent — an empty subclass, or one that overrides nothing the parent didn't already do.

Agent

A subclass that no longer differs meaningfully from its parent; the agent navigating the hierarchy traverses indirection for no behavioral variation.

Goal
Human

A subclass that no longer differs meaningfully from its parent merges back in.

Agent

The subclass folds into the parent; the agent reads one class instead of a degenerate two-class hierarchy.

Before the refactoring

class Employee {}
class FullTimeEmployee extends Employee {}

After the refactoring

class Employee {}
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure
Human

Readers navigate a hierarchy that adds no value; ceremony around construction and dispatch persists; future maintenance must touch both classes for any change.

Agent

The agent's reasoning pays the hierarchy ceremony cost on every reference; future maintenance touches both classes for any change.

Tradeoff
Human

Collapsing too eagerly destroys an extension point the team will later want — only collapse when the variant has been zero-sum for a sustained period.

Agent

If the subclass documents a future variation (extension point, planned divergence), collapsing destroys it; the agent that collapses without checking forecloses options.

Relief
Human

Smaller hierarchy, less ceremony, fewer files to navigate.

Agent

Smaller hierarchy; less ceremony; the agent loads one class instead of navigating a degenerate two-class chain.

Trap
Human

Collapsing a hierarchy whose subclass is currently quiet but documents a real future variation — destroys an extension point the team will need to re-introduce later at higher cost.

Agent

Collapsing subclasses that document planned future variation destroys extension points the agent will need to re-introduce later at higher cost.