代码重构
What's refactoring
•The process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.
•A disciplined way to clean up code that minimizes the chances of introducing bugs
Why refactoring
•Reasons :
–Design improvement and maintainance
–Better readability
–Bugs
Bad Smell
•Duplicated Code
•Long Method
•Large Class
•Long Parameter List
•Data Clumps•Switch Statements
•Temporary Field
•Feature Envy
•Divergent Change
•Shotgun Surgery
•Switch Statements
•Temporary Field
•Feature Envy
•Divergent Change
•Shotgun Surgery
How
•Extract
•Move
•Rename
•Tests are essential
•Small steps
Misunderstanding
•Regular time?
•No tests?