Course notes taken for CSCB07/CSC207 at UofT (Software Design).

Introduction to refactoring.

Overview

Refactoring is restructuring code in a series of small, semantics-preserving transformations in order to make the code easier to maintain and modify.

When to Refactor

You should refactor any time you see better way to do things.

You can do it without breaking the code (unit tests).

You should not refactor if code is already stable and doesn’t need to change, or if it is someone else’s code.

Refactoring Process

Code Smells