65
Remove Subclass
Goal
A subclass whose only purpose was to encode a type code or add nothing collapses back into a field on the parent.
Before the refactoring
class Person {}
class Female extends Person {}
class Male extends Person {}After the refactoringclass Person {
constructor(gender) { this.gender = gender; }
}Savings
Smaller hierarchy; new variants are field values instead of new files; the parent regains its variability point as data.
Note
Removing a subclass referenced by name elsewhere (factories, registries) breaks those references — confirm no consumer is type-testing the subclass.