QamoosTech
Programming FundamentalsCode qualityIntermediate

Refactoring

Pronunciationree-FAK-ter-ing

Definition

Improving the structure of code without changing what it does, so it is easier to read and change.

Where you hear it

Code reviews, sprint planning, and technical-debt discussions.

Examples

  • Let's refactor this module before adding new features.
  • The tests passed before and after the refactoring.
  • We refactored the billing module into smaller functions, and no behaviour changed.

Common mistake

Refactoring without tests. If you cannot prove the behavior is unchanged, you are just rewriting.

Don't confuse with

Refactoring changes the internal structure without altering external behavior, while rewriting discards the existing code to build it again from scratch.

Say it at work

  • In a meeting or chatI will spend the afternoon refactoring this messy function to make it easier to read.
  • In an email or ticketPlease ensure that all unit tests pass after completing the refactoring for this module.