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

Refactoring Dojo and the Gilded Rose Kata @swkcgn

Refactoring Dojo and the Gilded Rose Kata @swkcgn

At the Softwerkskammer Cologne, we did the Gilded Rose Kata. As introduction to refactoring, I talked using these decks about the major principles behind refactoring.

Steve Korzinetzki

February 19, 2018
Tweet

More Decks by Steve Korzinetzki

Other Decks in Programming

Transcript

  1. Code Duplication Deodorant Comment Speculative Generality Refused Bequest Large Class

    Long Parameter List Divergent Change ShotGun Surgery Feature Envy Data Clumps Switch Statements Primitive Obsession Inappropriate Intimacy Lazy Class Temporary Field Message Chains Long Method Middle Man Parallel Inheritance Hierarchy Alternative Classes with Different Interfaces Conditional Complexity Combinatorial Explosion Black Sheep
  2. Code Duplication Deodorant Comment Speculative Generality Refused Bequest Large Class

    Long Parameter List Divergent Change ShotGun Surgery Feature Envy Data Clumps Switch Statements Primitive Obsession Inappropriate Intimacy Lazy Class Temporary Field Message Chains Long Method Middle Man Parallel Inheritance Hierarchy Alternative Classes with Different Interfaces Conditional Complexity Combinatorial Explosion Black Sheep
  3. Catalog of Refactorings Composing Methods Moving Features Between Objects Organizing

    Data Simplifying Conditional Expressions Making Method Calls Simpler Dealing with Generalization Big Refactorings
  4. Catalog of Refactorings Composing Methods Moving Features Between Objects Organizing

    Data Simplifying Conditional Expressions Making Method Calls Simpler Dealing with Generalization Big Refactorings
  5. Example Refactoring: Decompose Conditional if (date.before (SUMMER_START) || date.after (SUMMER_END))

    { charge = quantity * _winterRate + _winterServiceCharge; } else { charge = quantity * _summerRate; }
  6. Example Refactoring: Decompose Conditional if (date.before (SUMMER_START) || date.after (SUMMER_END))

    { charge = quantity * _winterRate + _winterServiceCharge; } else { charge = quantity * _summerRate; } if (notSummer(date)) { charge = winterCharge(quantity); } else { charge = summerCharge(quantity); }
  7. Any Fool can write code, that a Computer understands. good

    Programmers write code, that humans understand. Martin Fowler Refactoring: Improving The Design of existing Code
  8. First Make the change easy, (Warning: this might be hard!)

    then make the easy change Kent Beck Author of Extreme Programming
  9. Photo Credits KRanhaus by Thorsen Hansen: https://www.flickr.com/photos/th_hansen/11151520553/ Trash by Vladimer

    Shioshvili: https://www.flickr.com/photos/vshioshvili/246797594/ Coins by Rodrigo Amorim: https://www.flickr.com/photos/zetotal/3840452595/ USS Roosevelt (DDG 80) by U.S. Naval Forces Central Command/U.S. Fifth Fleet: https://www.flickr.com/photos/navcent/15068556901/ Safety Net by Chad: https://www.flickr.com/photos/iamchadhearmesnore/3629410556/ photograph 287 By Tianna Spicer: https://www.flickr.com/photos/tiannaspicer/8618453971/ Learning to walk by Tela Chhe: https://www.flickr.com/photos/telachhe/3342173731/ Stay On Target By Pete: https://www.flickr.com/photos/comedynose/7865159650/ Adrenaline as an obsession by Erlend Aaby: https://www.flickr.com/photos/erlendaaby/8959485642/ Referees by Ronnie Macdonald: https://www.flickr.com/photos/ronmacphotos/14871566117/ Hopeless by Gauthier DELECROIX: https://www.flickr.com/photos/gauthierdelecroix/36059288880/ Game Programmer at work by Sergey Galyonkin: https://www.flickr.com/photos/sergesegal/11512594484/ Santiago Garza by Santiago Garza: https://www.flickr.com/photos/151318721@N02/34684657560/ IMGP3193 By François MORARD: https://www.flickr.com/photos/45368675@N03/16064828445/ Any Questions? By Nan Palmero: https://www.flickr.com/photos/nanpalmero/9370593260/ Gold fisher by peter: https://www.flickr.com/photos/stockispicts/10982462243