Back to list
vuralserhat86

refactoring-patterns

by vuralserhat86

OS for Agents: 130+ Agentic Skills, Gemini Protocols, and Autonomous Workflows. (Antigravity System)

19🍴 9📅 Jan 23, 2026

SKILL.md


name: refactoring_patterns router_kit: FullStackKit description: Common refactoring patterns - Extract, Rename, Move ve code smell çözümleri. metadata: skillport: category: quality tags: [architecture, automation, best practices, clean code, coding, collaboration, compliance, debugging, design patterns, development, documentation, efficiency, git, optimization, productivity, programming, project management, quality assurance, refactoring, refactoring patterns, software engineering, standards, testing, utilities, version control, workflow] - refactoring-strategies

🔄 Refactoring Patterns

Common refactoring patterns ve code smell çözümleri.


🎯 Altın Kural

Davranışı DEĞİŞTİRME, sadece yapıyı iyileştir

Before: Input X → [Code A] → Output Y
After:  Input X → [Code B] → Output Y (AYNI!)

🔍 Code Smells

SmellÇözüm
Long MethodExtract Method
Large ClassExtract Class
Duplicate CodeExtract + Reuse
Long Parameter ListParameter Object
Feature EnvyMove Method
Data ClumpsExtract Class

📦 Extract Method

// ❌ 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);
}

🔄 Replace Conditional with Polymorphism

// ❌ 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

🔄 Workflow

Kaynak: Refactoring.guru & Martin Fowler - Refactoring

Aşama 1: Preparation (Safety First)

  • Red-Green-Refactor: Testin var mı? Yoksa önce test yaz ("Characterization Tests"), sonra refactor et.
  • Small Steps: Değişiklikleri atomik commitler halinde yap. Her adımda testleri çalıştır.
  • Backup: VCS (Git) üzerinde temiz bir dalda çalış.

Aşama 2: Applying Patterns

  • Simplification: Karmaşık koşulları Decompose Conditional veya Replace Nested Conditional with Guard Clauses ile basitleştir.
  • Abstraction: Extract Method ve Extract Class ile sorumlulukları (SRP) ayır. Primitive Obsession varsa Value Object'e çevir.
  • Modernization: var -> const/let, for -> map/filter, Callback -> Async/Await dönüşümlerini uygula (Dil özelliklerini kullan).

Aşama 3: Verification & Cleanup

  • Regression Testing: Mevcut fonksiyonların bozulmadığını doğrula.
  • Dead Code: Kullanılmayan kodları (Dead Code) acımasızca sil. Yorum satırına alma, sil (Git geçmişinde var zaten).
  • Naming: Değişken ve fonksiyon isimlerini, kodun ne yaptığını değil "neden" yaptığını anlatacak şekilde güncelle.

Kontrol Noktaları

AşamaDoğrulama
1Refactoring sırasında yeni özellik eklendi mi? (KESİNLİKLE HAYIR. İki şapka kuralı: Ya Refactor yap ya Feature ekle).
2Kodun okunabilirliği arttı mı? (Cognitive Complexity düştü mü?).
3Test kapsamı (Coverage) korundu mu?

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon