重构学习笔记之代码的坏味道

1.重复的代码 Duplicated code
 --Solution: Extract method,pull up method, form template method, subsititute algorithm, extract class

2.过长的函数Long method
 --Solution: Extract method, replace temp with query, introduce parameter object, perserve whole object, replace method with method object, decompose conditional

3. 过大类 Large class
 --Solution: Extract class, extract subclass, extract interface, duplicate observed data

4, 过长的参数列表
 --Solution: Replace parameter with method, perserve whole object, introduce parameter object

5.  发散式变化 Divergent Change
 --Solution: Extract class

6.  霰弹式修改 Shotgun Surgery
 --Solution: Move method, move field, inline class

7.  依恋情结 feature envy
 --Solution: Move method, Extract method

8. 数据泥团 Data clumps
 --Solution: Extract class,perserve whole object, introduce parameter object

9. 基本类型偏执 Primitive Obsession
 --Solution: Replace data value with object, replace type code with class/subclass, replace type code with state/strategy

10. Switch惊悚现身
 --Solution: Replace conditional with polymorphism

11. 平行继承体系Parallel inheritance Hierarchies
 --Solution: reference, move method/field

12. Lazy Class冗赘类
 --Solution: collapse Hierarchy, inline class

13. Speculative generality 夸夸其谈未来性
 --Solution: collapse Hierarchy, inline class, remove parameter, rename method

14. Temporary Field 令人迷惑的暂时值域
 --Solution: Extrace class, Introduce Null Object

15. Message Chains 过度耦合的消息链
 --Solution: Hide Delegate, extract method, move method

 16.Middle Man 中间转手人
  --Solution: Remove Middle man, Inline Method, Replace Delegation with Inheriance

  17. Inappropriate Intimacy 狎昵关系
   --Solution: Move method, Move Field, Change bidirectional Association to Unidirectional, Extrace class, Hide delegate

   18. Alternative Classes with Different interfaces 异曲同工的类
    --Solution: Rename method, Move method, Extrace superclass

    19.Incomplete Library Class 不完美的程序库类
     --Solution: Introduce foreign method, Introduce local extension

     20. Data Class 纯稚的数据类
     --Solution: Encapsulate Collection, Remove Setting method, Move method, Extrace method, Hide method

     21. Refused Bequest 被拒绝的遗赠
     --Solution: Replace Inheritance with Delegation

     22. Comments 过多的注释
     --Solutioni: Extrace Method, Rename Method, Introduce Assertion

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值