Slide 1

Slide 1 text

Refactoring Dojo Gilded Rose Kata Steve Korzinetzki @SWKCGN February 2018

Slide 2

Slide 2 text

code smells

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Technical Debt Ward CunningHam Signee of Agile Manifesto

Slide 6

Slide 6 text

Refactoring Martin Fowler Refactoring: Improving The Design of existing Code

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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); }

Slide 11

Slide 11 text

Refactoring Strategies Piecemeal Refactoring Nesting Parallel Change Evolved Target Caller Creates Graceful RetreaT etc...

Slide 12

Slide 12 text

Two Hats adding functions refactoring

Slide 13

Slide 13 text

safety net of automated tests

Slide 14

Slide 14 text

Approval Testing And The Golden Master

Slide 15

Slide 15 text

Make Baby Steps

Slide 16

Slide 16 text

Design Patterns as Goal For Refactoring Erich Gamma Gang of Four

Slide 17

Slide 17 text

Keep Solid Principles in Mind

Slide 18

Slide 18 text

Four Rules of Simple Design Kent Beck Author of Extreme Programming

Slide 19

Slide 19 text

Intermediate Steps may look worse before it‘s getting better

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

First Make the change easy, (Warning: this might be hard!) then make the easy change Kent Beck Author of Extreme Programming

Slide 22

Slide 22 text

Questions?!

Slide 23

Slide 23 text

Feedback

Slide 24

Slide 24 text

Resources

Slide 25

Slide 25 text

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