When to refactor:
- Duplication - violation of DRY
- Non-orthogonal design
- Outdated knowledge (changes in reqs)
- Performance
How to refactor effectively
- don’t refactor and add functionality at the same time
- have a test suite - run it as often as possible
- take short, deliberate steps
Links
- Refactoring.guru - website with lots of resources on refactoring, design patterns, SOLID principles, etc.
- Refactoring section on sourcemaking.com
- Antipatterns section on sourcemaking.com