When should we refactor? 1. Because you planned to, ''after'' a test passed*. 2. Something smells bad. 3. You need to add something, and want to make it easier. 4. Your pair wants to understand the code better. 5. You want to try an experiment with a different structure. 6. The code doesn't say something that it should 7. The code does say something that it shouldn't 8. The code says something more than once. 9. You want to make it easier to test. 10. Fixing bugs needs a lot of time. ''<-- please clarify'' 11. ... ''*'' if you refactored before it passed - meaning if you integrated new behavior into existing behavior - you would be integrating untested behavior. Only integrate tested behavior. ---- See also SourcesOfRework (which refactor is not) ---- CategoryRefactoring