Successfully reported this slideshow.
Your SlideShare is downloading. ×

Object calisthenics

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Continuous Delivery
Continuous Delivery
Loading in …3
×

Check these out next

1 of 28 Ad

More Related Content

Recently uploaded (20)

Advertisement

Object calisthenics

  1. 1. Object Calisthenics #tac2018 @AgileTorinoConf Ferdinando Santacroce @jesuswasrasta
  2. 2. “ 2 The word calisthenics comes from the ancient Greek words kalòs (καλός), beauty, and sthénos (σθένος), strength. @jesuswasrasta #tac2018
  3. 3. “ 3 So, here’s an exercise that can help you to internalize principles of good object-oriented design and actually use them in real life. Jeff Bay @jesuswasrasta #tac2018
  4. 4. 4 1. Only one level of indentation per method @jesuswasrasta #tac2018
  5. 5. 5 2. Don’t use ELSE keyword @jesuswasrasta #tac2018
  6. 6. 6 3. Wrap all primitives and strings @jesuswasrasta #tac2018
  7. 7. 7 4. First class collections (1) @jesuswasrasta #tac2018
  8. 8. 8 4. First class collections (2) @jesuswasrasta #tac2018
  9. 9. 9 5. One dot per line @jesuswasrasta #tac2018
  10. 10. 10 6. Don’t abbreviate @jesuswasrasta #tac2018
  11. 11. 11 7. Keep all entities small @jesuswasrasta #tac2018
  12. 12. 12 8. No classes with more than two instance variables @jesuswasrasta #tac2018
  13. 13. 13 9. No getters/setters/properties @jesuswasrasta #tac2018
  14. 14. 14 @jesuswasrasta #tac2018 Time to get stronger! Setup TicTacToe Kata 2 pomodoros Pair programming TDD Debriefing, Q&A
  15. 15. 15 @jesuswasrasta #tac2018 Board, Row, Circle, Cross? Too many objects? Did rules conflicted, sometimes? Does it felt weird or uncomfortable, maybe? Debriefing
  16. 16. 16 E n c a p s u l a t i o n
  17. 17. 17 P o l i m o r p h i s m
  18. 18. 18 N a m i n g
  19. 19. 19 1. Only one level of indentation per method @jesuswasrasta #tac2018 Single Responsibility Principle (S.O.L.I.D.) Extract method Extract objects (collaborators)
  20. 20. 20 2. Don’t use ELSE keyword @jesuswasrasta #tac2018 Polymorphism Behavioral Patterns Strategy Pattern (set algorithm at runtime) State Pattern (state machines)
  21. 21. 21 3. Wrap all primitives and strings @jesuswasrasta #tac2018 Primitive Obsession Anti-Pattern: using primitives to represent domain ideas
  22. 22. 22 4. First class collections @jesuswasrasta #tac2018 Encapsulation: Any class that contains a collection should contain no other member variables Give behaviors related to the collection a home
  23. 23. 23 5. One dot per line @jesuswasrasta #tac2018 Law of Demeter Only talk with your immediate friends, don’t talk to strangers Fluent interfaces allowed
  24. 24. 24 6. Don’t abbreviate @jesuswasrasta #tac2018 Naming “Clean Code” book, Robert C. Martin, Ch. 2 Meaningful, intention-revealing, pronounceable, searchable names Methos name too long? Maybe it does too many things...
  25. 25. 25 7. Keep all entities small @jesuswasrasta #tac2018 Single Responsibility Principle (again...) Class with 50 l.o.c, methods with 5 The “class that fits in the monitor” rule There’s no black & white, it’s all about trade-offs
  26. 26. 26 8. No classes with more than two instance variables @jesuswasrasta #tac2018 High cohesion, low coupling
  27. 27. 27 9. No getters/setters/properties @jesuswasrasta #tac2018 Tell, don’t ask Feature envy code-smell (extensive use of another class) They violates Open/Closed Principle (S.O.L.I.D.) Anemic Domain anti-pattern
  28. 28. 28 Thanks! Any questions? You can find me at: ▫ @jesuswasrasta ▫ http://about.me/ferdinando.santacroce

×