要讓軟體具備模組特質,相關元素得在一起。
本章介紹如何將函式、欄位和陳述式(Statement)移動到更合適的位置。
移動特性(Moving Features)的核心概念:把相關的東西放在一起。
這是達成高內聚、低耦合(High Cohesion, Low Coupling)的基礎。
mindmap
root((移動特性))
函式層級
Move Function
Move Field
陳述式層級
Move Statements into Function
Move Statements to Callers
Slide Statements
程式碼結構
Replace Inline Code with Function Call
迴圈處理
Split Loop
Replace Loop with Pipeline
清理
Remove Dead Code