refactor-generalization
Installation
SKILL.md
Refactor: Dealing with Generalization
Overview
These 12 techniques manage inheritance hierarchies — pulling shared behavior up, pushing specific behavior down, extracting common interfaces, and replacing inheritance with delegation (or vice versa). Correct generalization prevents code duplication across subclasses while avoiding over-engineering.
When to Use
- Sibling classes share duplicate methods or fields
- Subclass only uses a fraction of parent's interface (Refused Bequest)
- Adding a subclass in one hierarchy requires adding one in another (Parallel Inheritance)
- Abstract class has only one concrete subclass (Speculative Generality)
- Inheritance used for code reuse rather than true is-a relationships