Successfully reported this slideshow.
Your SlideShare is downloading. ×

Test Driving Legacy Code Mini Workshop

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 22 Ad

More Related Content

Similar to Test Driving Legacy Code Mini Workshop (20)

More from Fernando Cuenca (15)

Advertisement

Recently uploaded (20)

Test Driving Legacy Code Mini Workshop

  1. 1. Test Driving Legacy Code Breaking out of the “Legacy Code Dilemma”
  2. 2. About me… Developer since 1994 (C++ used to be my friend…) Agile Coach since 2009 fernando.a.cuenca@gmail.com @fer_cuenca
  3. 3. Big Thanks to our Sponsor! http://digitalfactory.scotiabank.com
  4. 4. Agenda TDD in the context of Legacy Code Practice Session 1 + Debrief BREAK Practice Session 2 + Debrief
  5. 5. So, what is “Legacy Code” anyways?
  6. 6. Code that actively prevents you from making changes Code we’re afraid to change Code where the design makes more design decisions than the programmer Code without Unit Tests
  7. 7. you could have a “magic button”… Pecha Kucha @ OOP 2015 "Is TDD dead? https://www.youtube.com/watch?v=9NANcPTbDBQ
  8. 8. Start Here TDD Write a failing test Make it pass Improve the Design
  9. 9. The Legacy Code Dilemma Michael Feathers “Working Effectively with Legacy Code”
  10. 10. Pinning Down Behaviour
  11. 11. Your turn now! 2 Practice sessions + Debrief We need to choose a common Programming Language Java C# Javascript Find a partner (we’ll switch for Session 2) Log in to my Cyber-Dojo: http://cyberdojo.ddns.net
  12. 12. Welcome to Ugly Trivia! What does the code do? What are the different RESPONSIBILITIES? How “good” or “bad” is this code? Why? How much “Technical Debt” does it have? Can you identify two distinct kinds of tests? What is the purpose of each?
  13. 13. Key Ideas
  14. 14. Adding More Characterization Tests What kinds of things are displayed? When? What’s the minimum number of players? What happens when a player rolls? How does the current location change? How are categories selected? How are coins awarded? What’s the order of the players? How big is the board? How is it traversed? What happens when the answer is correct? Incorrect? What are the rules around the “penalty box”?
  15. 15. Debrief: What was it like? What are most important insights you gained from the session? What was helpful / not-helpful? What will you do differently in the next session?
  16. 16. Let’s fix some defects! Fix typo when answering correctly ("Answer was corrent") Terminate nicely instead of throwing exceptions: when questions run out when rolling before adding players
  17. 17. Let’s add some new features! Backlog 1. Display the winner's name when the game ends 2. Display output in multiple languages Guidelines Cover, then modify Can you test-drive a replacement? Are your tests passing all the time? How small are your steps? Can you make them smaller?
  18. 18. Large-Scale Refactoring New Features 1. Configurable board size 2. New Category: Politics 3. When questions run out (in any category), the game ends and the player with the most coins wins 4. Different categories pay different amount of coins when answered correctly 5. if 2 people in a row answer incorrectly, the order of players inverts Guidelines Pick a feature to work on Agree on a “good design” for it. Sketch general incremental steps to get there
  19. 19. The Mikado Method (https://mikadomethod.wordpress.com)
  20. 20. Debrief: What was it like? What are most important insights you gained from this session? What was the overall feeling? How does the result compares to what you initially thought the outcome might be? How/Where could this approach be useful? What will you do differently tomorrow, back in the office?
  21. 21. Learning more
  22. 22. Thank you! And please, complete the feedback forms!!

Editor's Notes

  • We tend to associate two ideas with “Legacy Code”: old, and messy.
  • Cyber-dojo start-point: Ugly Trivia / With Tests
    Ask people to review the code in pairs
    Distribute responsibilities page (if people need guidance)
  • Distribute Characterization test list (if people are lost)
  • Focus is to practice “Cover, then modify”
    Distribute refactoring diagrams


    == BREAK ==

×