Robert C. Martin (Uncle Bob) adapted the Boy Scout motto for software: every time you touch code, leave it a little better.
In Practice
- Rename a confusing variable while fixing a bug
- Extract a helper function during a feature addition
- Add a missing test when reviewing adjacent code
Small, continuous improvements prevent code rot far more effectively than occasional large-scale refactoring projects.