Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Refactoring the Tennis Kata v2 (2016)

431 views

Published on

Introduction to Coding Dojo refactoring exercise with a few slides of Refactoring Theory and constraints to use no mouse.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Refactoring the Tennis Kata v2 (2016)

  1. 1. Coding Dojo: Refactoring the Tennis Kata October 2016 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.
  2. 2. Peter Kofler • Ph.D. (Appl. Math.) • Professional Software Developer for 15+ years • “fanatic about code quality” • I help development teams PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  3. 3. I help development teams with PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ● Professionalism ● Quality and Productivity ● Continuous Improvement
  4. 4. Mentoring PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ● Pair Programming ● Programming Workshops ● Deliberate Practice, e.g. Coding Dojos
  5. 5. Developing Quality Software Developers
  6. 6. Coding Dojo? Expectations?
  7. 7. Coding Dojo Mindset ● Safe place outside work ● We are here to learn ● Need to slow down ● Focus on doing it right ● Collaborative Game PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  8. 8. Dojo Structure ● Introduction 15' ● Coding 60' ● Retrospective 15' ● Break 15' ● Coding 60' ● Retrospective 15' ● etc. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  9. 9. Refactoring Refactoring is a technique for restructuring an existing body of code, altering its internal structure without changing its external behaviour. (Martin Fowler) PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  10. 10. Identify Code Smells ● Code Smells are indications of a deeper problem in the system. ● e.g. ● bad names, ● duplication, ● call chains, ● missing object orientation, ● etc. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  11. 11. Refactor Mercilessly PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ● mer·ci·less is defined as having or showing no mercy, cold-blooded, hard-boiled, heartless, insensitive, hard, pitiless, remorseless, ruthless, slash-and-burn, soulless, take-no-prisoners, unfeeling, unsympathetic ● e.g. „extract till you drop“ https://sites.google.com/site/unclebobconsultingllc/one-thing-extract-till-you-drop
  12. 12. TDD Skills ● Driving Development with Tests ● Designing Test Cases ● Designing Clean Code ● Refactoring Safely  PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  13. 13. Assignment: Tennis PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  14. 14. Scoring a Tennis Game ● The Scoring Algorithm is done. ● Covered by a complete suite of test. ● You need to clean-up the code. ● Refactor Mercilessly! ● Work in small steps. („Baby Steps“) ● Rely on the tests, run them often. ● Experiment with approaches. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  15. 15. Constraints ● Challenges during a dojo or coderetreat ● Moving to the extreme is a way of learning ● Examples ● Missing Tool (No Mouse, …) ● Missing Feature (No IFs, …) PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  16. 16. Only Use Refactoring Tools PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  17. 17. Constraint: Refactoring Tools ● Using automatic refactoring is less risky. ● Only use refactoring tools of your IDE. ● e.g. Extract Variable, Inline Method, ... ● If you (have to) change code manually ● undo that change and ● think of a way to do the same change ● with a series of automatic refactorings. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  18. 18. Constraint: No Mouse PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  19. 19. Prepare ● Find a pair. ● Get the code. (“Download Zip”) ● Run tests, see many green tests. ● Start with TennisGame #2. ● Focus entirely on clean-up. ● Identify code smells. ● Try to use only automatic Refactorings. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  20. 20. Don't Focus on Getting it Done. F0cus on Doing It Perfectly.
  21. 21. →Practice
  22. 22. Closing Circle ● What did you learn today? ● What surprised you today? ● What will you do differently in the future? PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  23. 23. Peter Kofler @codecopkofler www.code-cop.org Kata by Emily Bache @emilybache http://coding-is-like-cooking.info/2011/08/refactoring-kata-fun/ PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  24. 24. CC Images ● Bruce http://www.flickr.com/photos/sherpas428/4350620602/ ● pairing http://www.flickr.com/photos/dav/94735395/ ● Dojo http://www.flickr.com/photos/49715404@N00/3267627038/ ● agenda http://www.flickr.com/photos/24293932@N00/2752221871/ ● smells http://www.flickr.com/photos/hhbw/4215183405/ ● mercy http://www.flickr.com/photos/williac/99551756/ ● Tennis http://www.flickr.com/photos/gagillphoto/3706167856/ ● tools https://www.flickr.com/photos/tom-margie/5019211728/ ● trap https://www.flickr.com/photos/stevendepolo/13714018553/ ● wants you http://www.flickr.com/photos/shutter/105497713/ PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

×