Last Revision — April 19, 2022
1 Min Read
---
Dispensables
Unnecessary Complexity
Between Classes
- Speculative Generality (caused)
William C. Wake in book (2004): "Refactoring Workbook"
If part of the code is not executed, it is a Dead Code. This code smell includes any place that the code executor will never reach, including the code that was commented out. Any if or case condition that cannot be reached, any code in methods and functions after the final return
statement, or any code inside a try
except
/catch
block that will never throw an error. [1] This usually is not that easy to detect and requires tool assistance. [2]
Never refactored long else-if blocks eventually have so many paths that no one even remembers if they are accessed anymore. Perhaps a new way of working was introduced, and the old code was never cleaned up.
Old code that was not deleted but commented out "just-in-case" is just bloating the codebase.