When to refactor When adding a feature¶ Refactoring helps you to understand code. If you have to deal with someone else's code, [[refactor]] it first. Clean code is easier to understand, will improve for yourself and others. Makes it easier to add new features and make changes. When fixing a bug¶ Bugs in code behave just like those in real life. [[Clean code]] and the [[error]]s will show up. Managers appreciate proactive refactoring as it eliminates the need for special refactoring tasks later. During a code review¶ The [[code review]] may be the last chance to tidy up before it becomes available for the public.