What is it?
- Programmers restructure the system without changing its behavior to remove duplication, improve communication, simplify, or add flexibility.
- improving the design without changing functionality
- improving communication, simplicity, flexibility
- removing duplication
- removing bad code-smells
Example Refactorings:
- combine or split classes
- rename method, variable, class
- migrate method up or down inheritance
- move block of code to method
Refactorings themselves not rocket science... but knowing how to refactor toward SimpleDesign takes experience.
Benefits:
- makes code easier to understand and modify
- makes it easier to find bugs
- makes it easier for the next person
- you might be the next person
- ===> faster development
Why should I refactor if my code works?
- to reverse entropy
- to make it simple
- to make it easy to extend
- to make it clean
If this is a "best practice", then why don't people do it?
- schedule pressure
- actually, well-refactored code makes programmers faster
- short-timer attitudes
- management doesn't understand, doesn't permit
- coders don't understand the code well enough to refactor it
- coders don't know how to do one tiny refactoring at a time
- no tests
How is it any different if done "eXtreme"?
- done very frequently in tiny tiny steps
What other practices support this practice?
What other practices are supported by this one?
How do I get started?
Next: PairProgramming
-- AndrewFuqua, JohnMHammer - 31 Mar 2002