Test, transform, refactor

4,671 views

Published on

Let's have a close look into the Red-Green-Refactor cycle and understand the subtleties of each step. When we go down the rabbit hole of Test Driven Design we sometimes take too big steps leading us to many failed tests we just can bring back to green without writing a lot of code. We need to take a step back and take the shrinking potion of baby steps again. This very illustrative talk, full of test and code examples, will dig into each of the steps of TDD to help you understand how to keep a sustainable pace that will lead you in the right track.

Published in: Technology

Test, transform, refactor

  1. 1. TEST, Test, Test, Test, Test, TRANSFORM, Transform, Transform, Transform, REFACTOR Refactor Refactor Refactor Refactor PHPUK 2014 by @_md
  2. 2. Learning @_md Marcello Duarte Lead developer Head of Training Kata sensei
  3. 3. @_md Marcello Duarte Lead developer Head of Training
  4. 4. Kata form movement practice deliberate
  5. 5. 20 minutes throw away TDD refactor Kata
  6. 6. Test Refactor Code
  7. 7. no code without test TDD 3Rules enough to go red enough to go green
  8. 8. no code without test Test enough to go red Code enough to go green
  9. 9. Refactor tests run and pass dry sign remove opacity De ple Sim simplify 4Rules
  10. 10. The Roman Numerals Kata
  11. 11. Converting arabic numbers into their roman equivalent ! e.g. 2149 => MMCXLIX
  12. 12. Test Make it red Code Make it green Refactor Make it right
  13. 13. The Roman Numerals Kata gone wrong demo
  14. 14. Introducing TPP
  15. 15. Test Make it more specific Transform Make it more generic Refactor Put on the design hat
  16. 16. null to constant constant to constant+ constant to scalar statement to statements unconditional to if if to while Transformations (just the most basic ones)
  17. 17. * in PHP http://www.flickr.com/photos/jorendegroof/4471189540/ Jim Weirich’s Roman Numeral Kata*
  18. 18. Walking skeleton [Cockburn 94]
  19. 19. Transformation null -> constant
  20. 20. Transformation unconditional -> if
  21. 21. Transformation statement -> statements
  22. 22. Transformation unconditional -> if
  23. 23. Refactor time?
  24. 24. Transformation if -> while
  25. 25. Condition to loop transformation ! is a great indicator you are in the right track of solving the algorithm [Martin 13]
  26. 26. Katas and Learning
  27. 27. Kata Deliberate Practice Koan Deliberate Learning • Optimising for performance • Optimising for discovery • Minimising variance • Maximising variance [North 12]
  28. 28. Learning TDD is learning all that TDD does for you
  29. 29. “The beauty of a move lies not in its' appearance but in the thought behind it.”
  30. 30. My System elements of chess positional play illustrative games
  31. 31. First learn the elements of design Then learn how to drive it with test
  32. 32. Marcello Duarte we are hiring try phpspec! follow @_md
  33. 33. inviqa.com/tdd-immersion-day/
  34. 34. Thank you !
  35. 35. Questions or Comments? joind.in/10711 @_md want to learn more? inviqa.com/tdd-immersion-day/

×