1. 重新组织函数
    1. Extract Method
    2. Inline Method
    3. Inline Temp
    4. Replace Temp with Query
    5. Introducing Explaining Variable
    6. Split Temporary Variable
    7. Remove Assignments to Parameters
    8. Replace Method with Method Object
    9. Substitute Algorithm
  2. 在对象间搬移特性
    1. Move Method
    2. Move Field
    3. Extract Class
    4. Inline Class
    5. Hide Delegate
      1. 解决Message Chain坏味道
    6. Remove Middle Man
      1. Hide Delegate的反向行为
    7. Introduce Foreign Method
    8. Introduce Local Extension
  3. 重新组织数据
    1. Self Encapsulate Field
    2. Replace Data Value with Object
    3. Change Value to Reference
      1. 希望将许多彼此相等的实例,替换成同一个对象
    4. Change Reference to Value
      1. 很小而不可变的引用对象,不再合适
    5. Replace Array with Object
    6. Duplicate Observed Data
    7. Change Unidirectional Association to Bidirectional
    8. Change Bidirectional Association to Unidirectional
    9. Replace Magic Number with Symbolic Constant
    10. Encapsulate Field
    11. Encapsulate Collection
      1. 让获取函数返回集合的副本,并且提供添加/移除元素的函数
    12. Replace Record with Data Class
    13. Replace Type Code with Class
      1. user defined type替代primitive type
    14. Replace Type Code with Subclasses
      1. 在自身上发展继承体系
      2. 首先需要Replace Constructor with Factory Method
    15. Replace Type Code with State/Strategy
      1. 类型可能会变化,或者自身无法发展继承体系。
    16. Replace Subclass with Fields
      1. 子类行为过于简单,已经没有存在必要
  4. 简化条件表达式
    1. Decompose Conditional
    2. Consolidate Conditional Expression
    3. Consolidate Duplicate Conditional Fragments
    4. Remove Control Flag
      1. 用break和continue等替代flag
    5. Replace Nested Conditional with Guard Clauses
      1. 如果条件表达式中只有一种是正常情况,异常情况可以作为卫语句
    6. Replace Conditional with Polymorphism
      1. 是Replace Type Code的继续工作
    7. Introduce Null Object
    8. Introduce Assertion
      1. 某段代码需要对程序状态做出假设,以断言明确表示这种假设
  5. 简化函数调用
    1. Rename Method
    2. Add Parameter
    3. Remove Parameter
    4. Separate Query from Modifier
      1. 明确表示出“有副作用”和“无副作用”函数之间的区别
    5. Parameterize Method
    6. Replace Parameter with Explicit Methods
      1. 一个函数,其中完全取决于参数而采取不同行为
      2. 针对参数的每一个可能值,建立一个独立函数
    7. Preserve Whole Object
      1. 参数
    8. Replace Parameter with Methods
      1. 以方法取代参数
    9. Introduce Parameter Object
    10. Remove Setting Methods
    11. Hide Method
      1. private
    12. Replace Constructor with Factory Method
      1. 希望在创建对象时不仅仅做简单的构建动作
      2. Replace Type Code时就用到了,根据Type Code生成不同子类的对象
    13. Encapsulate Downcast
    14. Replace Error Code with Exception
      1. 利用Exception来显示表明错误
    15. Replace Exception with Test
      1. 对Exception的滥用
  6. 处理概括关系
    1. Pull Up Field
    2. Pull Up Method
    3. Pull Up Constructor Body
      1. 各子类构造函数中有相似部分
    4. Push Down Method
    5. Push Down Field
    6. Extract Subclass
    7. Extract Superclass
      1. 两个类有相似特性
    8. Extract Interface
      1. 若干客户使用类接口中的同一子集
      2. 两个类的接口有相同部分
    9. Collapse Hierarchy
      1. 超类和子类无太大区别
    10. Form Template Method
      1. 相同的算法结构
    11. Replace Inheritance with Delegation
      1. 子类只使用超类接口中的一部分
      2. 或者根本不想要超类继承而来的数据
    12. Replace Delegation with Inheritance
      1. 两个类之间使用委托关系,并经常为整个接口编写简单的委托函数
  7. 大型重构
    1. Tease Apart Inheritance
      1. 某个继承体系同时承担着两项责任
      2. 建立两个继承体系,并通过委托关系让其中一个可以调用另外一个
    2. Convert Procedural Design to Objects
      1. 将数据记录变成对象
      2. 将大块的行为分为小块,并将行为移入相关对象之中
    3. Separate Domain from Presentation
      1. GUI类中包含了领域逻辑
      2. 将领域逻辑独立出来,为它们建立独立的领域类
    4. Extract Hierarchy
      1. 某个类做了太多工作,其中一部分工作是以大量条件表达式完成的
      2. 建立继承体系,以一个子类表示一种特殊情况
    5. 等等