2. WHAT IS REFACTORING
Refactoring is the process of changing a
software system in a way that does not
alter the external behavior of the code yet
improves its internal structure
3. WHY SHOULD WE REFACTOR
• Refactoring Improves the Design of Software
• Refactoring Makes Software Easier to Understand
• Refactoring Helps Find Bugs
• Refactoring Helps Program Faster
4. WHY SHOULD WE REFACTOR
“I’m not a great programmer; I’m
just a good programmer with great
habits.”
Kent Beck
5. WHY SHOULD WE REFACTOR
• Quality
• Clean code
• Profesionalizm
• Right Thing
6. WHY SHOULD WE REFACTOR
• Quality
• Clean code
• Profesionalizm
• Right Thing
Economy
8. WORKFLOWS OF REFACTORING
• TTD Refactoring
• Litter-Pickup Refactoring
• Comprehension Refactoring
• Preparatory Refactoring
• Planned Refactoring
• Long Term Refactoring
9. BAD SMELLS IN CODE
Indications that there is trouble that
can be solved by a refactoring
10. BAD SMELLS IN CODE
• Mysterious Name
• Duplicated Code
• Long Function
• Long Parameter List
• Global Data
• Mutable Data
• Divergent Change
• Shotgun Surgery
• Feature Envy
• Middle Man
• Insider Trading
• Large Class
• Alternative Classes with
Different Interfaces
• Data Class
• Refused Bequest
• Comments
• Data Clumps
• Primitive Obsession
• Repeated Switches
• Loops
• Lazy Element
• Speculative Generality
• Temporary Field
• Message Chains
11. BAD SMELLS IN CODE
• Mysterious Name
• Duplicated Code
• Long Function
• Long Parameter List
• Global Data
• Mutable Data
• Divergent Change
• Shotgun Surgery
• Feature Envy
• Middle Man
• Insider Trading
• Large Class
• Alternative Classes with
Different Interfaces
• Data Class
• Refused Bequest
• Comments
• Data Clumps
• Primitive Obsession
• Repeated Switches
• Loops
• Lazy Element
• Speculative Generality
• Temporary Field
• Message Chains
12. BLOATERS
Bloaters are code, methods and classes
that have increased to such gargantuan
proportions that they are hard to work with.
Usually accumulate over time
22. EXAMPLE RECIPE
• If you can obtain one parameter by asking another parameter for it, you can use Replace
Parameter with Query
• Rather than pulling lots of data out of an existing data structure, you can use Preserve Whole
Object
• If several parameters always fit together, combine them with Introduce Parameter Object
• If a parameter is used as a flag to dispatch different behavior, use Remove Flag Argument
• when multiple functions share several parameter values. Then, you can use Combine
Functions into Class
Long Parameter List
23. BIBLIOGRAPHY
Refactoring Improving the Design of Existing Code
by Martin Fowler, with Kent Beck
Clean Code: A Handbook of Agile Software Craftsmanship
by Robert C. Martin
The Pragmatic Programmer: From Journeyman to Master
by Andy Hunt
Head First Design Patterns
by Eric Freeman