| 信号 | 同一枚举在多处 switch、新增分支容易漏改 |
|---|---|
| 手法 | Replace Conditional with Polymorphism、Extract Function |
| 权衡 | 分支少且稳定时,集中一处的 switch 未必更差 |
多态化方向
多态化方向
interface Shipping {
Money cost(Order o);
}
class Air implements Shipping { ... }
class Ground implements Shipping { ... }