Refactoring Improving the Design of Existing Code
Refactoring,a First Example
- A poorly designed system is hard to change.Hard because it is hard to figure out where the changes are needed.
- When you find you have to add a feature to a program,and the program's code is not structured in a convenient way to add the feature,<font color='red'>first refactor</font> the program to make it easy to add the feature, <font color='red'>then add the feature</font>.
- The first step in refactoring is building a solid set of tests.
- Refactoring changes the programs in <font color='red'>small steps</font>. If you make a mistake, it is easy to find the bug.
- Good code should communicate what it is doing clearly, and variable names are a key to clear code
- Any fool can write code that a computer can understand. Good programmers write code that human can understand.