Code is refactored after a code review has determined that changes need to be made to address code quality, performance, or architecture. To refactor code, complete one change at a time in accordance with the code review work item, and perform unit tests after each change. This approach minimizes potential code breakage. Use automated refactoring whenever possible as the automated processes are less likely to cause functionality to break.