Code Smell 29 - Settings / Configs
24 November, 2022
4
4
0
Contributors
Problems
•
Duplicated Code
•
Global usage
•
Testability and explosion of testing scenarios.
•
Complexity
Solutions
1.
Avoid Settings
2.
Create polymorphic objects. Inject them externally.
Examples
•
External Connection Settings
•
User settings
Sample Code
Wrong
Right
Detection
Exceptions
•
Sometimes we use Feature togging as a safeguard mechanism. This is acceptable in a legacy system. These toggles should be very short-lived in a CI/CD system.
•
Hyper parameter settings should be managed by configuration objects.
Tags
•
Conclusion
A system with 300 Boolean configurations has more test combinations (2 ^ 300), than the number of atoms in the universe (10 ^ 80).
Also known as
•
More Info
Simplicity is the soul of efficiency.