Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Refactoring legacy code using Approval testing

Refactoring legacy code using Approval testing

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.

Isidro López

February 01, 2019
Tweet

More Decks by Isidro López

Other Decks in Programming

Transcript

  1. 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 • ?
  2. 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!
  3. 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!!
  4. Interesting resources • Screencasts ◦ Screencast: refactoring legacy code with

    approval testing (Emily Bache) ◦ Screencast: testing and refactoring legacy code (Sandro Mancuso) ◦ Approval tests with Java • Books ◦ https://www.goodreads.com/book/show/44936.Refactoring ◦ Working effectively with legacy code (Michael Feathers)