Milano Legacy Coderetreat 2013

1,410 views

Published on

Published in: Technology, Education

Milano Legacy Coderetreat 2013

  1. 1. Legacy Coderetreat Milano 2013 Text 10 PRINT "Hello World" 20 Go to 10
  2. 2. #lcrm13
  3. 3. Format of the Day from 10:00 to 13:00 MORNING from 13:00 to 14:00 LUNCH from 14:00 to 17:00 AFTERNOON
  4. 4. 45 min coding 10 min retrospec 5 min break Format of the Day 45’ coding 10’ review 5’ break
  5. 5. •CHALLENGE •REPEAT •FEEDBACK DEEP PRACTICE
  6. 6. NO PRESSURE feel free to experiment
  7. 7. NO PRESSURE do not complete the task but master it
  8. 8. Practice
  9. 9. Refactoring •AUTOMATIC •MANUAL
  10. 10. Read Code
  11. 11. Test Code Characterize Behaviour
  12. 12. Design •BY CODE •BY TESTS •BY SMELLS
  13. 13. Rules
  14. 14. When you don’t pair ...
  15. 15. after each session Pair
  16. 16. DELETE YOUR CODE AFTER EACH SESSION
  17. 17. Playbook
  18. 18. Golden Master(aka characterization tests) session #1
  19. 19. # suppose that our legacy code is this program called ‘game’ $ game > GOLDEN_MASTER # after some changes we can check to see if behaviour has changed $ game > OUT-01 $ diff GOLDEN_MASTER OUT-01 # after some other changes we check again and... $ game > OUT-02 $ diff GOLDEN_MASTER OUT-02 # GOLDEN_MASTER and OUT-01 are the same # GOLDEN_MASTER and OUT-02 are different -> behaviour changed Golden Master(aka characterization tests)
  20. 20. # what about something with a random output? $ whatthecommit > I think I fixed a bug :-) > for great justice. > syntax > LOL! > ... # somewhere in the code... $ cat whatthecommit | ack -i ‘rand’ > 5: g = Random.new > 42: messages[g.rand(NUMBER_OF_MESSAGES)] Golden Master(aka characterization tests)
  21. 21. # sequence generators are initialized with a seed # two random sequence generators initialized with the same # seed are going to produce the same sequence of numbers $ irb 1.9.3 > g = Random.new 1.9.3 > (1..10).map{g.rand(1000)} => [691, 362, 997, 692, 236, 532, 687, 616, 218, 702] 1.9.3 > g = Random.new 1.9.3 > (1..10).map{g.rand(1000)} => [865, 186, 89, 382, 894, 708, 769, 850, 452, 85] 1.9.3 > g = Random.new(1) 1.9.3 > (1..10).map{g.rand(1000)} => [37, 235, 908, 72, 767, 905, 715, 645, 847, 960] 1.9.3 > g = Random.new(1) 1.9.3 > (1..10).map{g.rand(1000)} => [37, 235, 908, 72, 767, 905, 715, 645, 847, 960] Golden Master(aka characterization tests)
  22. 22. # we need to change the code to take somehow the seed $ whatthecommit --seed=42 > fix the bug, for realz > to those I leave behind, good luck! > herping the derp > changes > ... # so that with the same seed, the same code is going to # create the same output $ whatthecommit --seed=42 > fix the bug, for realz > to those I leave behind, good luck! > herping the derp > changes > ... Golden Master(aka characterization tests)
  23. 23. $ git clone https://github.com/gabrielelana/trivia.git $ cd triva # enjoy
  24. 24. session #1 Characterize the behaviour of the code with the golden master technique Test Code
  25. 25. # to get the already done golden master $ git merge golden-master
  26. 26. session #2 Refactoring & Design Refactor the code so that it will be easy to create a new category of questions
  27. 27. session #3 Test Code Put under test the roll method/ function
  28. 28. session #4 Read Code Mark all the smells in the code. Remove at least 3 of them
  29. 29. session #5 Remove all the duplication
  30. 30. session #6 Replacing the penalty rules should be a one line change!

×