Overview
Developers are humans, and humans are bad guessers [1]. Developers tend to create additional features in preparation for the future, guessing they will be useful, but that time never came. This problem lies within the human psychological nature and, contrary to their best intentions, it just clutters the code.
Causation
Psychologically, humans tend to anticipate scenarios and prepare for them.
Problems
The whole system is trying or expecting to do more than it is supposed to.
Each additional method, class, or module increases the required time and effort to understand it as a whole.
Example
1class Animal:
2 health: int
3
4class Human(Animal):
5 name: str
6 attack: int
7 defense: int
8
9class Swordsman(Human):
10 ...
11
12class Archer(Human):
13 ...
14
15class Pikeman(Human):
16 ...Refactoring
- Collapse Hierarchy
- Inline Function
- Inline Class
- Rename Method
Sources
- ORIGIN1999 · ISBN 978-0201485677