Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TDD For Mortals

227 views

Published on

TDD for mortals, covers TDD practices and advanced topic like hexagonal architecture

Published in: Software
  • Be the first to comment

  • Be the first to like this

TDD For Mortals

  1. 1. @kfirondev TDD For Mortals @kfirondev
  2. 2. @kfirondev The essence of TDD Use case: The throttler It is not enough Use case of server + testing strategy Hexagonal Architecture Agenda
  3. 3. @kfirondev The essence of TDD 01
  4. 4. @kfirondev@kfirondev THE ESSENCE OF TDD REFACTOR MAKE THE TEST PASS WRITE A FAILING TEST
  5. 5. @kfirondev Use case – the throttler 02
  6. 6. @kfirondev@kfirondev Get - prize Get - prize OK OK Get - prize Get - prize Already wonAlready played Get - prize Get - prize Get - prize Get - prize Get - prize Get - prize Get - prize Get - prize Get - prize Get - prize Already won Already won Already won Already won Already won Already won Already won Already won Already won Already won USER QUIZ PRIZE SERVER DATABASE
  7. 7. @kfirondev@kfirondev Get - prize Get - prize OK OK Get - prize Already played Get - prize Get - prize Get - prize Get - prize Get - prize Already won Already won Already won Already won Already won USER QUIZ PRIZE SERVER DATABASE FAIL FAST PATTERN T H R O T T L E R ROLLING WINDOW KEY (user-id) THROTTLER
  8. 8. @kfirondev Live coding – the throttler 03
  9. 9. @kfirondev LET’S CODE • https://github.com/kfiron/tdd-workshop- template • https://github.com/kfiron/java-one-demo- app
  10. 10. @kfirondev It is not enough 04
  11. 11. @kfirondev TDD is a journey, it is not just red-green-refactor
  12. 12. @kfirondev Some of your tests are likely to be flaky – I/O hell
  13. 13. @kfirondev Bad design of tests will get you breaking the whole project in every refactor
  14. 14. @kfirondev Refactoring – extracting another class from current class must not come with another test! it is refactor
  15. 15. @kfirondev Yes, the tests description are part of the code, but they are not compile – It might be stale
  16. 16. @kfirondev To random or not to random?
  17. 17. @kfirondev Each test must test only one thing
  18. 18. @kfirondev Matchers hell! Do we need complex matchers?
  19. 19. @kfirondev Mocks, Stubs, Fakes
  20. 20. @kfirondev TDD is test driven development or design? It is the developer to make proper abstractions!
  21. 21. @kfirondev Port and adapters (Hexagonal architecture) 05
  22. 22. @kfirondev Ports and adapters architecture http://blog.mattwynne.net/2012/05/31/hexagonal-rails-objects-values-and-hexagons/comment- page-1/
  23. 23. @kfirondev Functional programming Is a good way to get there
  24. 24. @kfirondev Hexagonal Architecture with FP gives result which is: Deterministic Separation of concerns Fast testing lifecycle Concurrent agnostic domain model
  25. 25. @kfirondev Use case server design with tests 06
  26. 26. @kfirondev Let’s do some white boarding
  27. 27. @kfirondev This is where you are going to present your final words. This slide is not meant to have a lot of text.Thank You! Any Questions? Kfir Bloch

×