Why?
Some rationale for me currently, and why my intuition now tells me to steer away from inheritance1:
- Software and the concept we try to model are hard to fit into a hierarchical taxonomy.
- An added reason for this is that most of the work that we do is ‘emerging’.
- When you inherit from a class you’re coupled to the behaviors of that parent class.
- When you go further than one level of inheritance the cost of change is much higher.
- A lesson I learned somewhere along the way.
- Might even be able to find the source somewhere.
- Other than having felt it myself working in legacy code bases that preferred inheritance.
- A lesson I learned somewhere along the way.
- The cost of software is inherently tied to the cost of changing the software.2
- Coupling increases the amount of things that need to change even if you only want to change one thing.
Footnotes
-
Unless there are very particular and strong reasons to do it. ↩
-
Kent Beck, https://www.youtube.com/watch?v=ZHpQs46xizQ ↩