Slides used during the Software Crafters Meetup session.
The session had two parts:
* An introduction and open discussion about concepts like legacy code and technical debt.
* A live-coding session to show a technique called "approval testing", applying it to cover with tests some "legacy code".
Refactoring legacy code using
Meetup SW Crafters Alicante, 22.01.2020
Hemos venido a jugar...
Desarrollador de software/producto
Teleco, Antropología Social y
Cultural, Executive MBA, CSM…
What is legacy code for you?
For some people, legacy code is about...
Code not developed by me
Code that you don't know
Code without tests
Code diﬃcult to maintain (diﬃcult to understand or change)
Code no longer supported
Code that you would prefer not to touch
What is technical debt for you?
Is technical debt always "bad"?
Debt metaphor by Ward Cunningham (1992)
“Shipping ﬁrst time code is like going into debt. A little debt
speeds development so long as it is paid back promptly with a
[...] The danger occurs when the debt is not repaid.”
About technical debt
The extra eﬀort that it takes to keep on working on the code
is the interest paid on the debt.
It slows you down in baby steps, not realizing and taking for
granted that “it is the way it is”.
OK in isolated and stable areas which are “never” touched.
Technical Debt Quadrant
How to refactor (complex) legacy code?
We do not have tests as safety net before starting to refactor!
But… what if it is not really clear what is the current behavior?
Approval testing to the rescue!!
It also exists something called Golden Master
"Approval testing is a test technique which compares the current output of your code
with an "approved" version. The approved version is created by initially examining the
test output and approving the result."
Assume the current behaviour is correct: the ﬁrst goal is to refactor in a safe way!!
Live Coding time!!
Resources: kata and approval testing
○ Description of the kata
● Approval testing
Resources: screencasts and books
○ Refactoring legacy code with approval testing (Emily Bache)
○ Approval tests with Lift Kata (Emily Bache)
○ Testing and refactoring legacy code (Sandro Mancuso)
○ Approval tests with Java
● Emily Bache
○ How to develop new features with approval testing
Resources: refactoring and technical debt
Original writing about technical debt from Ward Cunningham
The Debt Metaphor (video)
Tech Debt - MPJ's Musings - Fun Fun Function