您的位置:首页 > 其它

Refactoring Improving the Design of Existing Code

2013-03-31 00:00 405 查看
1. Bad smells in code

2. Duplicated code

when same expression, Extract Method

sibling in subclass,extract method and pulll up method in super class

similar code ,but not identical,will extract Template method

3. Long Method

long Method is difficult understand.

small Method name will explain function.

logic in loop will extract method

replace method with method object

decompose conditional

4. Large Class

many instance and duplicated code will happen in large class

extarct subclass

extarct interface group by function

duplicate observed Data

5. Long Parameter List

difficulte to understand paramter

Preserve whole object

6. Divergent Change

7. Shotgun Surgery

Move method and move field in one class

8. Feature Envy

9. Data Clumps

10. Primitive Obsession

record type

primitive types

11. Switch Statements

cause by type code

replace type code with subclasses

replace type with state/strategy

replace conditional with polymorphism

replace parameter with Explicit methods

12. Parallel inheritance hieratchies

same pre in other class is bad smell

13. Lazy Class

14. Speculative generality
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: