Loading...
Loading...
Compare original and translation side by side
| Category | Techniques |
|---|---|
| Extraction | Extract Method, Extract Class, Extract Interface |
| Movement | Move Method, Move Field, Inline Method |
| Simplification | Replace Conditional with Polymorphism, Decompose Conditional |
| Organization | Introduce Parameter Object, Replace Magic Numbers |
| Legacy Migration | Strangler Fig, Branch by Abstraction, Parallel Change |
| 分类 | 技术手段 |
|---|---|
| 提取类重构 | Extract Method, Extract Class, Extract Interface |
| 移动类重构 | Move Method, Move Field, Inline Method |
| 简化类重构 | Replace Conditional with Polymorphism, Decompose Conditional |
| 组织类重构 | Introduce Parameter Object, Replace Magic Numbers |
| 遗留代码迁移 | Strangler Fig, Branch by Abstraction, Parallel Change |
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Long Method │ │ Large Class │ │ Long Parameter │
│ > 20 lines? │ │ > 200 lines? │ │ List │
│ → Extract Method │ │ → Extract Class │ │ → Parameter Object │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Long Method │ │ Large Class │ │ Long Parameter │
│ > 20 lines? │ │ > 200 lines? │ │ List │
│ → Extract Method │ │ → Extract Class │ │ → Parameter Object │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Switch Statements │ │ Refused Bequest │ │ Parallel │
│ Type-checking? │ │ Unused inheritance?│ │ Hierarchies │
│ → Polymorphism │ │ → Delegation │ │ → Move Method │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Switch Statements │ │ Refused Bequest │ │ Parallel │
│ Type-checking? │ │ Unused inheritance?│ │ Hierarchies │
│ → Polymorphism │ │ → Delegation │ │ → Move Method │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘┌─────────────────────┐ ┌─────────────────────┐
│ Divergent Change │ │ Shotgun Surgery │
│ One class, many │ │ One change, many │
│ reasons to change? │ │ classes affected? │
│ → Extract Class │ │ → Move/Inline │
└─────────────────────┘ └─────────────────────┘┌─────────────────────┐ ┌─────────────────────┐
│ Divergent Change │ │ Shotgun Surgery │
│ One class, many │ │ One change, many │
│ reasons to change? │ │ classes affected? │
│ → Extract Class │ │ → Move/Inline │
└─────────────────────┘ └─────────────────────┘./references/| File | Pattern | Use Case |
|---|---|---|
| Extract Method | Long methods → focused functions |
| Replace Conditional | switch/if → polymorphic classes |
| Parameter Object | Long params → structured objects |
| Strangler Fig | Legacy code → gradual migration |
./references/| 文件 | 模式 | 适用场景 |
|---|---|---|
| Extract Method | 冗长方法 → 单一职责函数 |
| Replace Conditional | switch/if语句 → 多态类 |
| Parameter Object | 冗长参数列表 → 结构化对象 |
| Strangler Fig | 遗留代码 → 渐进式迁移 |
./scripts/validate-refactoring.sh./scripts/validate-refactoring.sh