本文其实就是《重构改善既有代码的设计》的目录,便于读者初步对该书内容的了解!
1. Why
便于阅读、解耦、增强可拓展行、增强系统的健壮性!
2. When (何时)
2.1 Duplicated Code (重复代码) P76
2.2 Long Method (过长函数) P76
2.3 Large Class (过大的类) P78
2.4 Long Parameter List (过长的参数列) P78
2.5 Divergant Change (发散式变化) P79
2.6 Shotgun Surgery (散弹式修改) P80
2.7 Feature Envy (依恋情结) P80
2.8 Data Clumps (数据泥团) P81
2.9 Primitive Obsession (基本类型偏执) P81
2.10 Switch Statements (switch 惊悚现身) P82
2.11 Parallel Inheritane Hierarchies (平行继承体系) P83
2.12 Lazy Class (冗余类) P83
2.13 Speculative Generality (夸夸其谈未来性) P83
2.14 Temporary Field (令人迷惑的暂时字段) P84
2.15 Messsage Chains (过度耦合的消息链) P84
2.16 Middle Man (中间人) P85
2.17 Inappropriate Intimacy (狎昵关系) P85
2.18 Alternative Classes with Diffrent Interfaces (异曲同工的类) P85
2.19 Incomplete Library Class (不完美的类库) P86
2.20 Data Class (纯雉的数据类) P86
2.21 Refused Bequest (被拒绝的馈赠) P87
2.22 Comments (过多的注释) P87
3.How (怎么做)
====================第6章 重新组织函数===================
3.1 Extract Method(提炼函数) P110
3.2 Inline Method (内联函数) P117
3.3 Inline Temp (内敛临时变量) P119
3.4 Replace Temp with Query (以查询函数取代临时变量) P120
3.5 Introduce Explaining Variable (引入解释型变量) P124
3.6 Split Temporary Variable (分解临时变量) P128
3.7 Remove Assignments to Parameters (移除对参数的赋值) P131
3.8 Replace Method with Method Object (以函数对象取代函数) P135
3.9 Substitute Algorithm (替换算法) P139
===================第7章 在对象之间搬移特性==============
3.10 Move Method (搬移函数) P142
3.11 Move Field (搬移字段) P146
3.12 Extract Class (提炼类) P149
3.13 Inline CLass (将类内敛化) P154
3.14 Hide Delegate (隐藏“委托关系”) P157
3.15 Remove Middle Man (移除中间人) P160
3.16 Introduce Foreign Method (引入外加函数Utils) P162
3.17 Introduce Local Extension (引入本地扩展) P164
==================第8章 重新组织数据======================
3.18 Self Encapsulate Field (自封装字段) P171
3.19 Replace Data Value with Object (以对象取代数据值) P175
3.20 Change Value to Reference (将值对象改为引用对象) P179
3.21 Change Reference to Value (将引用对象改为值对象) P183
3.22 Replance Array with Object (以对象取代数组) P186
3.23 Duplicate Observed Data (复制“被监视数据”) P189
3.24 Change Unidirectional Association to Bidirectional (将单项关联改为双向关联) P197
3.25 Change Bidirectional Association to Unidirectional (将双向关联改为单项关联) P200
3.26 Replace Magic Number with Symbolic Constant (以字面量取代魔法数) P204
3.27 Encapsulate Field (封装字段) P206
3.28 Encapsulate Collection (封装集合) P208
3.29 Replace Record with Data Class (以数据取代记录) P217
3.30 Replace Type Code with Class (以类取代类型码) P218
3.31 Replace Type Code with Subclasses (以子类取代类型码) P223
3.32 Replace Type Code with State/Strategy (以State/Stratecy取代状态码) P227
3.33 Replace Subclass with Fields(以字段取代子类) P232
====================第9章 简化条件表达式=================
3.34 Decompose Condictional (分解条件表达式) P238
3.35 Consolidate Conditional Expression (合并条件表达式) P240
3.36 Consolidate Duplicate Conditional Fragments (合并重复条件片段) P243
3.37 Remove Control Flag (移除控制标记) P245
3.38 Replace Nested Conditional with Guard Clauses (以卫语句取代嵌套条件表达式) P250
3.39 Replace Conditional with Polymoephism (以多态取代条件表达式) P255
3.40 Introduce Null Object (引入Null对象) P260
3.41 Introduce Assertion (引入断言) P267
==================第10章 简化函数调用===================
3.42 Rename Method (函数改名) P273
3.43 Add Parameter (添加参数) P275
3.44 Remove Parameter (移除参数) P277
3.45 Separate Query from Modifier (将查询函数和修改函数分离) P279
3.46 Parameterize Method (令函数携带参数) P283
3.47 Replace Paramter with Explicit Methods (以明确函数取代参数) P285
3.48 Preserve Whole Object (保持对象完整性) P288
3.49 Replace Parameter with Methods (以函数取代参数) P292
3.50 Introduce Parameter Object (引入参数对象) P295
3.51 Remove Setting Methods (移除设值函数) P300
3.52 Hide Method (隐藏函数) P303
3.53 Replace Constructor with Factory Method (以工厂函数取代构造函数) P304
3.54 Encapsulate Doencast (封装向下转型) P308
3.55 Replace Error with Exception (以异常取代错误码) P310
3.56 Replace Exception with Test (以测试取代异常) P315
==================第11章 处理概括关系=====================
3.57 Pull Up Field (字段上移) P320
3.58 Pull Up Method (函数上移) P322
3.59 Pull Up Constructor Body (构造函数本体上移) P325
3.60 Push Down Method (函数下移) P328
3.61 Push Down Field (字段下移) P329
3.62 Extract Subclass (提炼子类) P330
3.63 Extract Superclass (提炼超类) P336
3.64 Extract Interface (提炼接口) P341
3.65 Collapse Hierarchy (折叠继承体系) P344
3.66 From Template Method (塑造模板函数) P345
3.67 Replace Inheritance with Delegation (以委托取代继承) P352
3.68 Replace Delegation with Inheritance (以继承取代委托) P355
==================第12章 大型重构=========================