| name | refactoring_strategies |
| description | Safe refactoring süreci - test-first, incremental changes ve güvenlik ağı. |
🛡️ Refactoring Strategies
Safe refactoring süreci ve incremental değişiklikler.
⏰ Ne Zaman Refactor?
| Sinyal | Aksiyon |
|---|
| Code Smell | Refactor et |
| Before feature | Zemin hazırla |
| After bug fix | Kodu iyileştir |
❌ Ne Zaman YAPMA
- Deadline çok yakın
- Test coverage düşük
- Sistemi anlamadan
🔒 Güvenlik Ağı
describe('calculateTotal', () => {
test('single item', () => {
expect(calculateTotal([{ price: 100, qty: 1 }])).toBe(100);
});
test('multiple items', () => {
expect(calculateTotal([
{ price: 100, qty: 2 },
{ price: 50, qty: 1 }
])).toBe(250);
});
test('empty array', () => {
expect(calculateTotal([])).toBe(0);
});
});
📊 Incremental Strategy
- Test yaz → Mevcut davranışı belgele
- Küçük değişiklik → Tek bir şeyi değiştir
- Test çalıştır → Hala geçiyor mu?
- Commit → Küçük, atomik commit
- Tekrarla
✅ Checklist
Refactoring Strategies v1.1 - Enhanced
🔄 Workflow
Kaynak: Working Effectively with Legacy Code & Refactoring to Patterns
Aşama 1: Safety Net (Test First)
Aşama 2: Strategic Patterns
Aşama 3: Lifecycle Management
Kontrol Noktaları
| Aşama | Doğrulama |
|---|
| 1 | Test paketi 2 dakikanın altında çalışıyor mu? (Hızlı feedback). |
| 2 | Veritabanı şeması değişiyor mu? (Migration planı var mı?). |
| 3 | Rollback planı test edildi mi? |