重构手法
- JDK1.8+
影片租赁销售机,重构过程依次涉及的重构手法:
- Extract Method(提炼方法)
- Inline Temp(内联变量)
- Rename Variable(重命名变量)
- Move Method + Rename method(移动方法)
- Replace Temp with Query(以查询取代临时变量)
- Form Template Method(构造模板方法)
- Replace Type Code with State/Strategy(以State/Strategy取代类型码)
- Replace Conditional with Polymorphism(以多态取代条件表达式)
- Self Encapsulate Field(自封装字段)
- EM: Extract Method
- RTWQ: Replace Temp with Query
- STV: Split Temporary Variable
- RMWMO: Replace Method with Method Object
- MM: Move Method
- MF: Move Field
- RDVWO: Replace Data Value with Object
- CVTR: Change Value to Reference
- CRTV: Change Reference to Value
- RAWO: Replace Array with Object
- RTCWS: Replace Type Code with Subclass
- RTCWS/S: Replace Type Code with State/Strategy
- RNCWGC: Replace Nested Conditional with Guard Clauses