37

Collapse Hierarchy


Goal

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

Before the refactoring
class Employee {}
class FullTimeEmployee extends Employee {}
After the refactoring
class Employee {}
Savings

Smaller hierarchy, less ceremony, fewer files to navigate.

Note

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