`

Refactoring -- Improving the Design of Existing Code

 
阅读更多


重构名录:
         第一部分:代码的坏味道(Bad smells in Code)
                   BS1: Duplicated Code(重复的代码)
BS2:Long Method(过长的函数)
                   BS3:Large Class(过大类)
                   BS4: Long Parameter List(过长参数列)
                   BS5:Divergent Change (发散式变化)
                   BS6:Shotgun Surgery (散弹式修改)
                   BS7: Feature Envy (依恋情节)
                   BS8: Data Clumps(数据泥团)
                   BS9: Primitive Obsession(基本型别偏执)
                   BS10: Switch Statements(Switch 惊悚现身)
                   BS11: Parallel Inheritance Hierarchies(平行继承体系)
                   BS12: Lazy Class(冗赘类)
                   BS13: Speculative Generality(夸夸其谈未来性)
                   BS14: Temporary Field(令人迷惑的暂时值域)
                   BS15: Message Chains(过度耦合的消息链)
                   BS16: Middle Man(中间转手人)
                   BS17: Inappropriate Intimacy(狎昵关系)
                   BS18: Alternative Classes with Different Interface
                   BS19: Incomplete Library Class(不完美的程序库类)
                   BS20: Data Class(纯数据类)
                   BS21: Refused Bequest(被拒绝的遗赠)
                   BS22: Comments(过多的注释)

         第二部分:重新组织你的函数
1.    Extract Method(提炼函数)
2.    Inline Methods(将函数内联化)
3.    Inline Temp(将临时变量内联化)
4.    Replace Temp with Query
5.    Introduce Explaining Variable
6.    Split Temporary Variable
7.    Remove Assignments to Parameters
8.    Replace Method with Method Object
9.    Substitute Algorithm


第三部分:在对象之间搬移特性
10.    Move Method
11.    Move Field
12.    Extract Class
13.    Inline Class
14.    Hide Delegate
15.    Remove Middle Man
16.    Introduce Foreign Method
17.    Introduce Local Extension
第四部分: 重新组织数据
18.    Self Encapsulate Field (自封装值域)
19.    Replace Data Value with Object(以对象取代数据)
20.    Change Value to Reference(将实值对象改为引用对象)
21.    Change Reference To Value(将引用对象改为实值对象)
22.    Replace Array With Object(以对象取代数组)
23.    Duplicate Observed Data(复制被监视数据)

第五部分:简化条件表达式
24.    Decompose Conditional(分解条件式)
25. Consolidate Conditional Expression(合并条件式)
26. Consolidate Duplicate Conditional Fragments(合并重复条件片段)
27. Remove Control Flag
28. Replace Nested Conditional with Guard(以卫语句取代嵌套条件式)
29. Replace Condition with polymorphism(以多态取代条件式)
30. Introduce Null Object (引入null对象)
31. Introduce Assertion (引入断言)

第六部分:简化函数调用
32. Rename Method
33. Add Parameter
34. Remove Parameter
35. Separate Query from Modifier
36. Parameterize Method
37. Replace Parameter with Explicit Methods
38. Preserve Whole Object
39. Replace Parameter with Methods
40. Introduce Parameter Object
41. Remove Setting Method
42. Hide Method
43. Replace Constructor with Factory Method
44. Encapsulate Downcast
45. Replace Error Code with Exception
46. Replace Exception with Test

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics