Presentation to support a talk and live coding session facilitated in Spotify.
With an introduction to reflect together about what legacy code or technical debt are, there was a live coding demo based on the Gilded Rose kata, in order to cover it with tests using the "approval testing" tools.
Refactoring legacy code using
CSAT Lunch & Learn, 01.02.2019
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 difficult to maintain (difficult to understand or change)
Code no longer supported
What is technical debt for you?
Is technical debt always "bad"?
Technical Debt Quadrant
How to refactor (complex) legacy code?
But… what if it is not really clear what is the current behavior?
We do not have tests as safety net before starting to refactor!
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 first goal is to refactor in a safe way!!
Gilded Rose refactoring kata
Description of the kata
○ Screencast: refactoring legacy code with approval testing (Emily Bache)
○ Screencast: testing and refactoring legacy code (Sandro Mancuso)
○ Approval tests with Java
○ Working effectively with legacy code (Michael Feathers)
Thanks for the feedback!!