/*
Author: Jiangong SUN
*/
There is a list of refactoring techniques with examples.
http://www.refactoring.com/catalog/
1. Duplicated code
Extract method or Extract class
2. Long method
Extract method, Inline method, replace temp variable by query, Parameter object(DTO), Replace method by method object
http://www.refactoring.com/catalog/splitTemporaryVariable.html
3. Large class
Extract class, extract subclass,
4. Long parameter list
Preserve whole object, Introduce parameter object
5. Divergent change发散式变化
Extract class: divide class into different sub classes, in this way, several changes in a class can be made into several sub classes.
6. Shortgun surgery 霰弹修改; 和发散式变化正相反
Move method, move field: put all codes need to be modified into a class for preventing from forgetness in a lot of differenct classes.
7. Feature Envy 依恋情结
symptom: a method use a lot of method in another class.
Move method, Strategy, Visitor pattern
8. Data clumps 数据泥团
9. Primitive obsession 基本类型偏执
Replace data value with object, replace type code with class
10. Switch statements : switch 惊悚现身
Replace conditional with polymorphism
11. Parallel inheritance hierarchies 平行继承体系
symptom: when you create a subclass for a class, you have to create a subclass for another class.
solution: make sure that instances of one hierarchy refer to instances of the other
12. Lazy class冗赘类
symptom: a class is not doing a lot of work
solution: inline class, means moving all it's features into another class.
13. speculative generality 夸夸其谈未来性
remove parameter, collapse hierarchy, inline class
14. temporary field 暂时字段
extract class, introduce nullable object
15. message chains过度耦合的信息链
symptom: You see message chains when a client asks one object for another object, which the client then asks for yet another object, which the client then asks for yet another another object, and so on.
solution: hide delegate
16. middle man 中间人
delegate
17. inappropriate intimacy 不合适的亲昵行为
extract method, extract class
18. alternative classes with different interfaces
19. incomplete library class
20. data class
21. refused requests
22. comments
Extract method, Rename method