December 10, 2022
This code smell happens when we add functionality that isn't really needed but we believe will be needed in the future ๐ฎ. It often takes place in the form of unused data (parameters, fields in objects, columns in the database schema, among others), unused methods, and unnecessary classes.
Why is it bad? ๐
- This leads to code that is more complex ๐คฏ than it has to be, and is harder to maintain over the long run.
- Unnecessary functionality is a waste ๐๏ธ of time and resources.
How to fix it? ๐ง
- Remove unused parameters. ๐งผ
- Remove unused method signatures when overloading. ๐งน
- Remove unnecessary classes and functions.๐งฝ
- Keep the structure of the code simple ๐: avoid over-engineering ๐ง ๐ง the solution and always keep the use case in mind.
Details ๐ต๏ธ: https://refactoring.guru/smells/speculative-generality