Back to Catalog
Code Smells
Change Preventers
Parallel Inheritance Hierarchies
Two or more class hierarchies that grow in parallel.
Intent & Description
'
🎯 Intent
Identify when you have to make changes to multiple inheritance hierarchies simultaneously.
📋 Context
Creating a subclass in one hierarchy requires creating a corresponding subclass in another hierarchy.
💡 Solution
Merge the hierarchies or eliminate the dependency between them using composition.'
Real-world Use Case
Use when adding a class to one hierarchy requires changes to another.
Source
📌 TL;DR
Parallel hierarchies create unnecessary coupling. Merge them or use composition to break the dependency.