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.

D99c2a3a8f27cffbcd0a390286aba109?s=128

Steve Korzinetzki

February 19, 2018
Tweet

Transcript

  1. Refactoring Dojo Gilded Rose Kata Steve Korzinetzki @SWKCGN February 2018

  2. code smells

  3. 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
  4. 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
  5. Technical Debt Ward CunningHam Signee of Agile Manifesto

  6. Refactoring Martin Fowler Refactoring: Improving The Design of existing Code

  7. Catalog of Refactorings Composing Methods Moving Features Between Objects Organizing

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

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

    { charge = quantity * _winterRate + _winterServiceCharge; } else { charge = quantity * _summerRate; }
  10. 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); }
  11. Refactoring Strategies Piecemeal Refactoring Nesting Parallel Change Evolved Target Caller

    Creates Graceful RetreaT etc...
  12. Two Hats adding functions refactoring

  13. safety net of automated tests

  14. Approval Testing And The Golden Master

  15. Make Baby Steps

  16. Design Patterns as Goal For Refactoring Erich Gamma Gang of

    Four
  17. Keep Solid Principles in Mind

  18. Four Rules of Simple Design Kent Beck Author of Extreme

    Programming
  19. Intermediate Steps may look worse before it‘s getting better

  20. 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
  21. First Make the change easy, (Warning: this might be hard!)

    then make the easy change Kent Beck Author of Extreme Programming
  22. Questions?!

  23. Feedback

  24. Resources

  25. 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