2. @andreafrancia
The conservative approach
No automatic tests
leads to
Manual testing
that leads to
High risk of introduce bugs
that leads to
Fear of change
so
You prefer add more mess instead cleaning up the existing code
and
the code get worse,
the cost/time of adding features increases
If it ain't broke don't fix it
3. @andreafrancia
The Legacy Code Dilemma
When we refactor, we should have tests.
To put tests in place, we often have to refactor
4. @andreafrancia
Trip Service Kata
• Sandro Mancuso (@sandromancuso)
• https://github.com/sandromancuso/trip-service-
kata
• http://www.slideshare.net/MozaicWorks/sandro-
mancuso-testing-and-refactoring-legacy-code
5. @andreafrancia
Requisiti di business
Considerate un social network per viaggiatori.
• Devi essere loggato per vedere i contenuti del
sito.
• Devi essere un amico per poter vedere i viaggi di
un altro utente.
6. @andreafrancia
Le regole del legacy code
• Puoi modificare solo il codice di produzione che è
coperto dai test
• (al massimo puoi usare solo i safe refactoring nel
caso siano necessari per mettere il codice sotto
test)