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

Refactoring When You Literally Can't Even

Refactoring When You Literally Can't Even

Refactoring is the process of changing the structure of a codebase without changing its external behavior. In addition to being an important part of ongoing development, it can also be used to get a legacy codebase under control.

Using the Gilded Rose Kata as a basis, this workshop explores how to refactor a legacy codebase safely, even when you don't yet understand what the code is doing.

Randy Coulman

May 12, 2016
Tweet

More Decks by Randy Coulman

Other Decks in Programming

Transcript

  1. www .codingzeal.com @codingzeal Randy Coulman a.k.a. Refactron Refactoring When You

    Literally Can’t Even Senior Software Engineer @randycoulman
  2. The System • Sell_in: the number of days we have

    to sell the item • Quality: how valuable the item is • End of each day: lower both values for every item
  3. The Spec: Can We Trust It? • Once the sell-by

    date has passed, quality degrades twice as fast • The quality of an item is never negative • “Aged Brie" actually increases in quality the older it gets • The quality of an item is never more than 50 • "Sulfuras", being a legendary item, never has to be sold or decreases in quality • "Backstage passes", like aged brie, increases in quality as its sell-by date approaches; quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less, but quality drops to 0 after the concert.
  4. Mob Programming • One computer for programming • One driver

    • N navigators and researchers http://mobprogramming.org/mob-programming-basics/
  5. What is Refactoring? “a disciplined technique for restructuring an existing

    body of code, altering its internal structure without changing its external behavior” http://refactoring.com
  6. When to Refactor? An ongoing part of your workflow Test-Driven

    Development (TDD) Cycle: Red -> Green -> Refactor
  7. Why Refactor? Ideal: Make the code look like it would

    have looked if the feature you just added had always been there
  8. Want More? Original Gilded Rose Kata http://craftsmanship.sv.cmu.edu/katas/gilded-rose-kata Gilding the Rose

    Talk at GoGaRuCo 2014 http://confreaks.tv/videos/gogaruco2014-gilding-the-rose-refactoring-legacy-code Code from GoGaRuCo 2014 Talk https://github.com/randycoulman/GildedRose
  9. References Working Effectively With Legacy Code: Michael Feathers http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052 Refactoring:

    Martin Fowler http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672 Refactoring Ruby Edition: Jay Fields, Shane Harvie, and Martin Fowler http://www.amazon.com/Refactoring-Ruby-Jay-Fields/dp/0321603508