You have found the more you change the code, the more difficult it becomes. Refactoring is a developer practice of improving the internal structure of existing code without changing the external behaviour. It makes code changes for present or future easier. You may have heard about Refactoring from colleagues, books, articles and have probably tried or hear it the first time. This talk presents what it is, why it is important and what you can do to get better at it based on the experience of mentoring on technical practices to others. This talk is suitable for people who are experienced in programming, have met the challenges of making changes and want to deepen their skill. Demo included!
13. A NATURE OF SOFTWARE DEVELOPMENT
AMOUNT OF
"BAD” CODE
# BUGS
TIME SPENT
ON FIXING
BUGS
PANIC
QUICK HACKS
MOTIVATION OF
DEVELOPERS
CASUAL LOOP
DIAGRAM
14. A NATURE OF SOFTWARE DEVELOPMENT
REQUIREMENTS
TIME
(you)
(competitor)
COMPETING BY CHANGE
15. The Management of Computer Programming Projects
Charles Lecht - 1967
Equally responsible for the initiation of project with
predefined failure is management that insists upon having
fixed commitments from programming personnel prior to
the latter’s understanding what the commitment are for.
Too frequently, management does not realize that in
asking the staff for “the impossible”, the staff will feel the
obligation to respond out of respect, fear or misguided
loyalty. Saying “no” to the boss frequently requires
courage, political and psychological wisdom, and
business maturity that comes with much experience.
16. A NATURE OF SOFTWARE DEVELOPMENT
AMOUNT OF
"BAD” CODE
# BUGS
TIME SPENT
ON FIXING
BUGS
PANIC
QUICK HACKS
MOTIVATION OF
DEVELOPERS
AMOUNT OF
CODE SMELLS
REFACTORING
OPPORTUNITY FOR
INDICATES
18. REFACTORING
“…IS A DISCIPLINED TECHNIQUE FOR
RESTRUCTURING AN EXISTING BODY OF
CODE, ALTERING ITS INTERNAL
STRUCTURE WITHOUT CHANGING ITS
EXTERNAL BEHAVIOR.”
MARTIN FOWLER
INTRODUCE
PARAMETER OBJECT
EXTRACT CLASS
INTRODUCE
LOCAL VARIABLE
RENAME
MOVE METHODEXTRACT METHOD
INLINE VARIABLE
19. Q: WHEN DO WE REFACTOR?
A: WHEN THE CODE SMELLS!
20. CODE SMELLS
“A CODE SMELL IS A SURFACE
INDICATION THAT USUALLY
CORRESPONDS TO A DEEPER PROBLEM
IN THE SYSTEM”
MARTIN FOWLER
DUPLICATED CODE
MAGIC NUMBER
FEATURE ENVY
PRIMITIVE OBSESSION
LONG METHOD
COMMENTS
45. HOW TO START
ESSENTIAL SKILLS
▸ Explain the code with design principles
▸ Identify code smells
▸ Refactor either manually or through IDE
▸ Familiar working with unit/integration tests
▸ Familiar with the functionality you’re changing