Notes: Refactoring -- Bad Smells in Code

 
  1. Duplicated Code
    1. In a class: Extract Method
    1. Sibling classes:
  • Extract Method -> Pull Up Method(superclass)
  • Extract Method -> Form Template Method
  • Substitute Algorithm
  1. Extract Class
  1. Long Method (Comments)
    1. Extract Method
    1. Replace Temp with Query
    1. Introduce Parameter Object/Preserve Whole Object
    1. Replace Method with Method Object
    1. Decompose Conditional
  1. Large Class
    1. Extract Class
    1. Extract Subclass
    1. Extract Interface
    1. Duplicate Observed Data (GUI class)
  1. Long Parameter List (Dependency structure)
    1. Replace Method with Method Object
    1. Preserve Whole Object
    1. Introduce Parameter Object
  1. Divergent Change
    1. Extract Class (Strategy/Visitor/Self Delegation)
  1. Shotgun Surgery
    1. Move Method/ Move Field
    1. Inline Class
  1. Feature Envy
    1. Move Method
    1. Extract Method -> Move Method
  1. Data Clumps
    1. Extract Class
    1. Introduce Parameter Object/ Preserve Whole Object
  1. Primitive Obsession
    1. Replace Data Value with Object
    1. Replace Type Code with Class/Replace Type Code with Subclass/Replace Type Code with State/Strategy
    1. Extract Class
    1. Introduce Parameter Object
    1. Replace Array with Object
  1. Switch Statements (Polymorphism)
    1. Extract Method
    1. Move Method
    1. Replace Type Code with Subclass/Replace Type Code with State/Strategy
    1. Replace Conditional with Polymorphism
    1. Replace Parameter with Explicit Methods
    1. Introduce Null Object
  1. Parallel Inheritance Hierarchies (Shotgun Surgery)
    1. Move Method
    1. Move Field
  1. Lazy Class
    1. Collapse Hierarchy
    1. Inline Class
  1. Speculative Generality
    1. Collapse Hierarchy (abstract class)
    1. Inline Class (delegation)
    1. Remove Parameter
    1. Rename Method
  1. Temporary Field
    1. Extract Class
    1. Introduce Null Object
  1. Message Chains (structure of navigation)
    1. Hide Delegate
    2. Extract Method
    1. Move Method
  1. Middle Man (encapsulation/delegation)
    1. Remove Middle Man
    1. Inline Method
    1. Replace Delegation with Inheritance
  1. Inappropriate Intimacy
    1. Move Method/Move Field
    1. Change Bidirectional Association to Unidirectional
    1. Extract Class
    1. Hide Delegate
    1. Replace Inheritance with Delegation
  1. Alternative Classes with Different Interfaces
    1. Rename Method
    1. Move Method
    1. Extract Superclass
  1. Incomplete Library Class
    1. Introduce Foreign Method
    1. Introduce Local Extension
  1. Data Class
    1. Encapsulation Field
    1. Encapsulation Collection
    1. Remove Setting Method
    1. Move Method
    1. Extract Method
    1. Hide Method
  1. Refused Bequest
    1. Replace Inheritance with Delegation
  1. Comments
    1. Extract Method
    1. Rename Method
    1. Introduce Assertion

转载于:https://www.cnblogs.com/missair/archive/2010/10/22/1858655.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值