Refactoring = restrukturasi kode tanpa mengubah behavior. Referensi pattern dari Martin Fowler.
Catalog (by code smell)
| Smell | Refactoring |
|---|---|
| Long Method | Extract method, replace temp with query |
| Large Class | Extract class, extract subclass |
| Duplicated Code | Extract method, pull up field |
| Long Parameter List | Introduce parameter object |
| Switch Statement | Replace with polymorphism |
| Feature Envy | Move method |
Workflow
- Ensure tests exist (safety net)
- Identify code smell
- Apply refactoring (one at a time)
- Run tests (green?)
- Commit