O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Cqrs in babysteps

5.613 visualizações

Publicada em

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Cqrs in babysteps

  1. 1. Command Query Responsibility Segregation In Babysteps @talboomerik
  2. 2. Founder of Software craftsmanship guild Belgium @talboomerik
  3. 3. Thanks to @yreynhout @alastairs @sandromancuso @adibolb
  4. 4. And a special thanks to @StefanBilliet
  5. 5. ENTRY LEVEL INTRODUCTION @talboomerik
  6. 6. WHERE DID IT COME FROM? A little history @talboomerik
  7. 7. Command and Query Separation It states that every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer. More formally, methods should return a value only if they are referentially transparent and hence possess no side effects. Wikipedia - Bertrand Meyer @talboomerik
  8. 8. IF YOU HAVE A RETURN TYPE, YOU SHOULD NOT CHANGE STATE Query @talboomerik
  9. 9. IF YOU CHANGE STATE YOUR RETURN TYPE SHOULD BE VOID Command @talboomerik
  10. 10. BASICALLY CQRS IS CQS SPLIT IN DIFFERENT OBJECTS The simple definition @talboomerik
  11. 11. QUERY OBJECTS OVER QUERY SERVICES / REPOSITORIES http://lostechies.com/jimmybogard/2012/10/08/favor-query-objects-over-repositories/ @talboomerik
  12. 12. WHAT IS THIS ALL ABOUT? What’s the fuss @talboomerik
  13. 13. YOUR TYPICAL N-TIER ARCHITECTURE @talboomerik
  14. 14. http://codeofrob.com/entries/cqrs-is-too-complicated.html
  15. 15. REMEMBER WHAT UNCLE SANDRO SHOWED US?
  16. 16. FEELS FAMILIAR? @talboomerik
  17. 17. WE CAN MAKE THIS SIMPLER @talboomerik
  18. 18. http://codeofrob.com/entries/cqrs-is-too-complicated.html
  19. 19. REMOVING QUERIES FROM YOUR DOMAIN MODEL @talboomerik @sandromancuso
  20. 20. @sandromancuso
  21. 21. LET’S TAKE IT ONE STEP FURTHER If needed @talboomerik
  22. 22. http://codeofrob.com/entries/cqrs-is-too-complicated.html
  23. 23. OR EVEN FURTHER If applicable @talboomerik
  24. 24. http://codeofrob.com/entries/cqrs-is-too-complicated.html
  25. 25. HOW TO SYNCHRONIZE READ/WRITE? @talboomerik
  26. 26. DOMAIN EVENTS A cool pattern @talboomerik
  27. 27. LET’S HAVE A LOOK AT SOME CODE @talboomerik
  28. 28. TAKING IT TO ANOTHER LEVEL Event sourcing @talboomerik
  29. 29. FOCUSING ON BEHAVIOR INSTEAD OF STATE @talboomerik
  30. 30. http://codeofrob.com/entries/cqrs-is-too-complicated.html
  31. 31. SOME MISCONCEPTIONS ABOUT CQRS @talboomerik
  32. 32. CQRS <> DDD It’s not the same @talboomerik
  33. 33. CQRS <> EVENT SOURCING They just go well together http://lostechies.com/jimmybogard/2012/08/22/busting-some-cqrs-myths/ @talboomerik
  34. 34. CQRS CAN HAVE AN IMMEDIATE CONSISTENT READ STORE http://lostechies.com/jimmybogard/2012/08/22/busting-some-cqrs-myths/ @talboomerik
  35. 35. CQRS DOES NOT FORCE YOU TO USE A BUS http://lostechies.com/jimmybogard/2012/08/22/busting-some-cqrs-myths/ @talboomerik
  36. 36. COMMANDS DO NOT NEED TO BE FIRE-AND-FORGET Accepting the request vs Fulfilling the request http://lostechies.com/jimmybogard/2012/08/22/busting-some-cqrs-myths/ @talboomerik
  37. 37. WHY IS THIS A GOOD IDEA? Pros and cons @talboomerik
  38. 38. SIMPLER DOMAIN MODEL By splitting @talboomerik
  39. 39. BETTER SEPARATION OF CONCERNS AND RESPONSIBILITIES @talboomerik
  40. 40. SCALABILITY Technical and team @talboomerik
  41. 41. COMPLETE REBUILD OF THE APPLICATION STATE THROUGH EVENT SOURCING http://martinfowler.com/eaaDev/EventSourcing.html @talboomerik
  42. 42. TEMPORAL QUERYING Replay history http://martinfowler.com/eaaDev/EventSourcing.html @talboomerik
  43. 43. AUDIT LOG I see you http://martinfowler.com/eaaDev/EventSourcing.html @talboomerik
  44. 44. IT DOES REQUIRE “SOME” WORK UPFRONT Set up infrastructure @talboomerik
  45. 45. IT WORKS BEST WITH TASK-BASED UI Delivery mechanism and domain architecture need to collaborate
  46. 46. IT IS NOT EASY It’s a big shift from what we are used to @talboomerik
  47. 47. HOW CAN WE GET THIS DONE? Code, show us code @talboomerik
  48. 48. THANK YOU That’s all folks @talboomerik

×