Refactoring - Improving The Design Code
This is just a summary. For complete detail please refer to the book written by Martin Fowler.
Why Should You Refactor
When Should You Refactor
What Should You Refactor
How To Refactor
Why Should You Refactor
- Improves the design of softwaren
- Makes software easier to understand
- Helps you find bugs
- Helps you program faster
When Should You Refactor
- When you do something similar three times.
- When you add function
- When you need to fix a bug
- When you do a code review
What Should You Refactor
- Duplicated code
- Long method
- Large class
- Long parameter list
- Divergent change
- Shotgun Surgery - the opposite of divergent change, everytime you make a kind of change, you have to make a lot of little changes to a lot of different classes.
- Comments - good codes don't need long comments.
- Lazy class
- Temporary field
- etc (refer the book)
How To Refactor
- Build unit tests
- Run the tests
- Commit the codes
- Refactor
- Run the tests again.
- If something goes wrong, fix it until the tests run.
- If you can't fix it, revert the codes which is comitted on step 3.
- If everything is okay, commit the codes again.

Comments