refactoring_patterns
Common refactoring patterns - Extract, Rename, Move ve code smell çözümleri.
npxskills add vuralserhat86/antigravity-agentic-skills--skill refactoring_patternsLoading…
Common refactoring patterns - Extract, Rename, Move ve code smell çözümleri.
npxskills add vuralserhat86/antigravity-agentic-skills--skill refactoring_patternsLoading…
Common refactoring patterns ve code smell çözümleri.
Davranışı DEĞİŞTİRME, sadece yapıyı iyileştir
Before: Input X → [Code A] → Output Y
After: Input X → [Code B] → Output Y (AYNI!)
| Smell | Çözüm |
|---|---|
| Long Method | Extract Method |
| Large Class | Extract Class |
| Duplicate Code | Extract + Reuse |
| Long Parameter List | Parameter Object |
| Feature Envy | Move Method |
| Data Clumps | Extract Class |
// ❌ Before
function processOrder(order) {
// 20 lines of validation
// 30 lines of calculation
// 15 lines of formatting
}
// ✅ After
function processOrder(order) {
validateOrder(order);
const total = calculateTotal(order);
return formatOutput(total);
}
// ❌ Before
function getPrice(type) {
if (type === 'premium') return 100;
if (type === 'basic') return 50;
return 30;
}
// ✅ After
const pricing = { premium: 100, basic: 50, free: 30 };
const getPrice = (type) => pricing[type] ?? 30;
Refactoring Patterns v1.1 - Enhanced
Kaynak: Refactoring.guru & Martin Fowler - Refactoring
Decompose Conditional veya Replace Nested Conditional with Guard Clauses ile basitleştir.Extract Method ve Extract Class ile sorumlulukları (SRP) ayır. Primitive Obsession varsa Value Object'e çevir.var -> const/let, for -> map/filter, Callback -> Async/Await dönüşümlerini uygula (Dil özelliklerini kullan).| Aşama | Doğrulama |
|---|---|
| 1 | Refactoring sırasında yeni özellik eklendi mi? (KESİNLİKLE HAYIR. İki şapka kuralı: Ya Refactor yap ya Feature ekle). |
| 2 | Kodun okunabilirliği arttı mı? (Cognitive Complexity düştü mü?). |
| 3 | Test kapsamı (Coverage) korundu mu? |
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).