Polyglot heaven

1,231 views

Published on

A presentation about data and how to build polyglot applications. The key component, as I see it, to build polyglot data applications is to use an event store as the master data storage and then use other types of databases as views of that data. The presentation also touches on Command Query Responsibility Segragation, CQRS, and event sourcing.

Published in: Software
  • Be the first to comment

Polyglot heaven

  1. 1. POLYGLOT HEAVEN How to Build an Async, Reactive Application in 2014 NDC London Tomas Jansson 04/12/2014
  2. 2. POLYGLOT HEAVEN How to Build an Async, Reactive Application in 2014 NDC London Tomas Jansson 04/12/2014 And this should probably be 2015 This here, a title to get accept
  3. 3. THIS IS ME Tomas Jansson Manager & Practice Lead .NET BEKK Oslo @TomasJansson tomas.jansson@bekk.no github.com/mastoj blog.tomasjansson.com
  4. 4. AGENDA WHY ASYNC AND REACTIVE? LET’S TALK DATA WHY POLYGLOT? WHAT CAN WE DO? DEMO SUMMARY
  5. 5. WHY ASYNC AND REACTIVE? - ASYNC Async doesn’t mean unreliable Async gives you responsiveness Data will be consistent
  6. 6. WHY ASYNC AND REACTIVE? - REACTIVE Message based  modular React on change Eventual consistent
  7. 7. LET’S TALK DATA Let’s talk Data
  8. 8. LET’S TALK DATA Are all data the same?
  9. 9. LET’S TALK DATA What different kinds of data do we have?
  10. 10. LET’S TALK DATA Changes, state, relations, cache...
  11. 11. ”if all you have is a hammer, everything looks like a nail” Why polyglot?
  12. 12. WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS Documents
  13. 13. WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS Documents Document database
  14. 14. WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS Documents Document database Changes
  15. 15. WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS Documents Document database Changes Event store
  16. 16. WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS Documents Document database Changes Event store Relations
  17. 17. WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS Documents Document database Relations Graph database Changes Event store
  18. 18. What can we do?
  19. 19. Change!
  20. 20. 3-LAYERED ARCHITECTURE – WHY OH WHY?
  21. 21. 3-LAYERED ARCHITECTURE – WHY OH WHY? You are mixing your domain with your query model!
  22. 22. What do you think about ”Divide and Conquer?”
  23. 23. COMMAND QUERY RESPONSIBILITY SEGREGATION - CQRS CQRS is ”Divide and Conquer” applied on a architecutral level
  24. 24. CQRS WITH EVENT SOURCING - OVERVIEW ApplicationCommand Events Events Projection View
  25. 25. CQRS WITH EVENT SOURCING - OVERVIEW Application: f(x, ys)  ys’, x: Command, ys: list of Events Projection: f(y, ys)  z, y: Event, ys: list of Events, z: View
  26. 26. CQRS WITH EVENT SOURCING - OVERVIEW Application: f(x, ys)  ys’, x: Command, ys: list of Events Projection: f(y, ys)  z, y: Event, ys: list of Events, z: View Your application is a pure function! How you implement it is secondary, the events are what matters!
  27. 27. CQRS WITH EVENT SOURCING - TESTS [Test] public void PlaceOrder_Should_CreateAnOrder() { var productId = Guid.NewGuid(); var customerId = Guid.NewGuid(); var orderId = Guid.NewGuid(); var orderItems = Contracts.Helpers.ToFSharpList(new[] {new OrderItem(productId, 20)}); Given(new ProductCreated(productId, "a name", 20), new CustomerCreated(customerId, "John Doe")); When(new PlaceOrder(orderId, customerId, orderItems)); Then(new OrderPlaced(orderId, customerId, orderItems)); } Pure functions are easy to test
  28. 28. WHAT WILL I SHOW TODAY? ApplicationCommand Events Events Projection View
  29. 29. WHAT WILL I SHOW TODAY? ApplicationCommand Events Events Projection View HTTP
  30. 30. THE KEY COMPONENT This is where the ”truth” is stored
  31. 31. Demo!
  32. 32. View databases Web Application View CreateCustomer CreateProduct PlaceOrder GetRecommendations GetCustomer GetProduct
  33. 33. SUMMARY Why async and reactive? • Responsive • Scalable • Modular
  34. 34. SUMMARY Why async and reactive? • Responsive • Scalable • Modular Why polyglot? • Not all data is the same • Not everything is a nail
  35. 35. SUMMARY Why async and reactive? • Responsive • Scalable • Modular Why polyglot? • Not all data is the same • Not everything is a nail Event sourcing and CQRS • CQRS is divide and conquer on an architecture level • Your application should be a function • You don’t have to write in a functional language to write functional code (but it might make it easier)
  36. 36. SUMMARY Why async and reactive? • Responsive • Scalable • Modular Why polyglot? • Not all data is the same • Not everything is a nail Event sourcing and CQRS • CQRS is divide and conquer on an architecture level • Your application should be a function • You don’t have to write in a functional language to write functional code (but it might make it easier)
  37. 37. http://www.slideshare.net/mastoj/polyglot- heaven https://github.com/mastoj/PolyglotHeaven http://open.bekk.no/polyglot-heaven-a- response-to-the-bekk-radar
  38. 38. Questions?
  39. 39. Thank you! @TomasJansson

×