Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Agile Design Episode 3 Workshop OCP Kata - Andrea Francia - TDD milano - 2017-12-14

Slide usate durante l'incontro: "Agile Design Episode 3 - Workshop OCP Kata" del TDD Milano il 14 dicembre 2017.

  • Soyez le premier à commenter

Agile Design Episode 3 Workshop OCP Kata - Andrea Francia - TDD milano - 2017-12-14

  1. 1. Agile Design Episode 3
 Workshop OCP Kata Andrea Francia @TDD Milano Giovedì 14 Dicembre 2017
  2. 2. Why design is important?
  3. 3. Kent Beck. 1999. Extreme Programming Explained: Embrace Change Legacy Code Clean Code
  4. 4. When Refactor?
  5. 5. http://agileinaflash.blogspot.it/2009/02/red-green-refactor.html
  6. 6. Refactor last? • RED • GREEN • REFACTOR
  7. 7. Refactor first? • REFACTOR • RED • GREEN
  8. 8. Refactor first and last • REFACTOR (to make easier add the new feature) • RED • GREEN • REFACTOR (to remove any duplication)
  9. 9. How long to stay in each phase?
  10. 10. http://agileinaflash.blogspot.it/2009/02/red-green-refactor.html
  11. 11. The TDD Rhythm: 1. Quickly add a test 2. Run all tests and see the new one fail 3. Make a little change 4. Run all tests and see them all succeed 5. Refactor to remove duplication
  12. 12. The TDD Rhythm: 1. Quickly add a test 2. Run all tests and see the new one fail 3. Make a little change 4. Run all tests and see them all succeed 5. Refactor to remove duplication
  13. 13. http://agileinaflash.blogspot.it/2009/02/red-green-refactor.html 1-2 minutes 1-2 minutes take your time
  14. 14. The Open/Closed Principle
  15. 15. The “O” in SOLID • Single Responsibility Principle (SRP) • Open/Closed Principle (OCP) • Liskov substitution Principle (LSP) • Interface Segregation Principle (ISP) • Dependency Inversion Principle (DIP)
  16. 16. The Open/Closed Principle • You should be able to extend the behavior of a system without having to modify that system. https://8thlight.com/blog/uncle-bob/2014/05/12/TheOpenClosedPrinciple.html
  17. 17. Open and Closed Open => we can add behavior just adding new pieces Closed => we don’t need change old pieces(*) (*) (no change => no test change, no deploy needed, no cascading changes )
  18. 18. Examples
  19. 19. Language libraries List<Integer> list = ...; // standard sort Collections.sort(list); printAll(list); // sorting with a specific comparator Collections.sort(list, new PronounceComparator()); printAll(list);
  20. 20. Hexagonal Architecture
  21. 21. How to learn to apply OCP?
  22. 22. Kata (repetition)
  23. 23. OCP Kata Open-Closed Principle Kata: http://matteo.vaccari.name/blog/archives/293
  24. 24. When do we refactor? Starting code base Changes implemented red == code changed (Hopefully) Code cleaned up Refactor after Starting code base Change design to make room for new feature Implement feature Refactor before From a slide by Dave Nicolette
  25. 25. OCP Kata Rules 1. Write the first failing test
  26. 26. OCP Kata Rules 1. Write the first failing test 2. Then write a factory that returns an object, or an aggregate of objects, that make the test pass.
  27. 27. The factory should be limited to creating objects and linking them together. No conditionals allowed.
  28. 28. OCP Kata Rules 1. Write the first failing test 2. Then write a factory that returns an object, or an aggregate of objects, that make the test pass. 3. Write the next failing test.
  29. 29. OCP Kata Rules 1. Write the first failing test 2. Then write a factory that returns an object, or an aggregate of objects, that make the test pass. 3. Write the next failing test. 4. Make the test pass by changing the factory and/or adding a new class and nothing else.
  30. 30. OCP Kata Rules 1. Write the first failing test 2. Then write a factory that returns an object, or an aggregate of objects, that make the test pass. The factory should be limited to creating objects and linking them together. No conditionals allowed. 3. Write the next failing test. 4. Make the test pass by changing the factory and/or adding a new class and nothing else. You can’t? Then refactor your code until you can!
  31. 31. Workshop time
  32. 32. The FizzBuzz Game 1, 2, Fizz!, 4, Buzz!, Fizz!, 7, 8, Fizz!, Buzz!, 11, Fizz!, 13, 14, FizzBuzz!, 16, 17, Fizz!... If the number is a multiple of 3, say “Fizz” If it is a multiple of 5, say “Buzz” If it is a multiple of 3 and 5, say “FizzBuzz” Otherwise, just say the number.
  33. 33. Workshop time
  34. 34. Retrospective
  35. 35. Grazie ocp@andreafrancia.it

×