Refactoring = restrukturasi kode tanpa mengubah behavior. Referensi pattern dari Martin Fowler.

Catalog (by code smell)

SmellRefactoring
Long MethodExtract method, replace temp with query
Large ClassExtract class, extract subclass
Duplicated CodeExtract method, pull up field
Long Parameter ListIntroduce parameter object
Switch StatementReplace with polymorphism
Feature EnvyMove method

Workflow

  1. Ensure tests exist (safety net)
  2. Identify code smell
  3. Apply refactoring (one at a time)
  4. Run tests (green?)
  5. Commit