Aesthetics and the Beauty of an Architecture

767 views

Published on

CQRS & Event Sourcing are patterns gaining traction and popularity. In this presentation given at Øredev 2013 it talks about real-world experiences using these patterns, the good, the bad and the ugly.

Published in: Technology, Spiritual
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
767
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
31
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Aesthetics and the Beauty of an Architecture

  1. 1. Aesthetics & the Beauty of an Architecture Adventures in CQRS & Event Sourcing Tom Scott @tomwscott
  2. 2. What’s in it for you? • Understanding of CQRS & Event Sourcing in the wild • The mistakes we made… • … the lessons we learnt … • … and why we’re still happy! rob.knight
  3. 3. 1 art |ɑːt| noun 1 [ mass noun ] the expression or application of human creative skill and imagination, typically in a visual form such as painting or sculpture, producing works to be appreciated primarily for their beauty or emotional power
  4. 4. 1 art |ɑːt| noun 1 [ mass noun ] the expression or application of human creative skill and imagination, typically in a visual form such as painting or sculpture, producing works to be appreciated primarily for their beauty or emotional power
  5. 5. Aesthetics
  6. 6. Aesthetics Scott’s Purely Arbitrary Criteria, Etceteras For Evaluating Beautiful Architectures #SPACE_FEBA
  7. 7. Fully Operational
  8. 8. Simplicity echerries
  9. 9. Commitment justageek
  10. 10. Deferring Commitment justageek
  11. 11. Metaphor Petar Pavlov - http://bit.ly/9ySEUt
  12. 12. Discipline & Consistency
  13. 13. Serendipity kathryn_rotondo
  14. 14. #SPACE_FEBA • Fully Operational • Simplicity • Deferred Commitment
 • Metaphor • Discipline • Serendipity
  15. 15. Price Comparison ££
  16. 16. The evolution of a system Presentation Application Database   |
  17. 17. The Solution archer10
  18. 18. Architectural Goals • Structured • Horizontal Scalability • Availability & Reliability
 • Visibility / Monitorability • Flexibility & Replaceability archer10
  19. 19. The Mandate! • Service Oriented Architecture • Domain Driven Design • Micro-Services
 • Continuous Delivery • Oh and one more thing! archer10
  20. 20. Domain Driven Design • Entity • Value Object • Aggregate • Service
 • Repository • Factory • Bounded Context archer10
  21. 21. Domain Driven Design • Entity • Value Object • Aggregate • Service
 • Repository • Factory • Bounded Context archer10
  22. 22. Service Oriented Architecture   
  23. 23. Understand your Domain    Home Journey Panel Quote Engine Risk Enquiry Provider Quote
  24. 24. T d? En he
  25. 25. Just one more thing… http://m.cdn.blog.hu/ke/kedvessigmund/image/columbo.jpg
  26. 26. CQRS & Event Sourcing • CQRS or “Why do we use the same schema for reads and writes?” • Event Sourcing or “Why do we allow ORMs to dictate our object model?” archer10
  27. 27. CQRS
  28. 28. Command Query Responsibility Segregation   } } write read
  29. 29. Use SQL?   {   {          “_id”  :  “590b9902”,   UPDATE  Address            “_id”  :  “590b9902”,          “event”  :  “AddressModified”,   SET     umber  =  10,     n        “event”  :  “PolicySpecified”,          “data”  :  {          street  =  ‘Downing  Street’,          “data”  :  {             “number”  :  10,   c           “type”  :  “ContentsInsurance”,               ity  =  ‘London’,     “street”  :  “Downing  Street”,   p             ostcode  =  ‘SW1A  2AA’     “excess”  :  750              “city”  :  “London”,     WHERE  _id  =  ‘590b9902’  }  “postcode”  :  “SW1A  2AA”     }  }     }
  30. 30. Event Sourcing (C#)      public  class  Customer  :  AggregateRoot        {                  private  readonly  Guid  id;   !                private  Address  currentAddress;                                  //  Business  Logic                  public  void  ChangeAddress(Address  newAddress)                  {                if  (newAddress.IsValid())             {                                 Raise(new  AddressModified(id,  newAddress));                                 }                  }                 !                //  State  Transition                  public  void  Apply(AddressModified  @event)                    {                          currentAddress  =  @event.Address;                  }   ! !       ! ! ......                  //  Business  Logic                  public  void  SpecifyCommunicationPreferences(CommunicationPrefs  preferences)                  {                          Raise(new  CommunicationPreferencesSpecified(id,  preferences));                                  
  31. 31. Eventual Consistency  POST /risk/new HTTP/1.1 302 ! GET /risk/590b9902:v1 Location: /risk/590b9902:v1
  32. 32. What we ended up with:       
  33. 33. The Conclusion tim_norris
  34. 34. ? Simple Metaphor ? Discipline Commitment + Fully Operational Serendipity
  35. 35. The Power!      public  class  Customer  :  AggregateRoot        {                  private  readonly  Guid  id;   !                private  Address  currentAddress;   !                public  void  ChangeAddress(Address  newAddress)                  {                                              Raise(new  AddressModified(id,  newAddress));                                        }   !                public  void  Apply(AddressModified  @event)                  {                          currentAddress  =  @event.Address;                  }          }
  36. 36. The Power!      public  class  Customer  :  AggregateRoot        {                  private  readonly  Guid  id;   !                private  Address  currentAddress;   !                public  void  ChangeAddress(Address  newAddress)                  {                          if  (currentAddress.IsSignificantlyDifferentFrom(newAddress))                          {                                  Raise(new  CustomerMoved(id,  newAddress));                          }                          else                          {                                  Raise(new  AddressModified(id,  newAddress));                          }                  }   !                public  void  Apply(CustomerMoved  @event)                  {                          currentAddress  =  @event.Address;                  }   !                public  void  Apply(AddressModified  @event)                  {                          currentAddress  =  @event.Address;                  }          }
  37. 37. The Flexibility! var  connection  =  rabbit.createConnection({  url:  ‘amqp://localhost:5672'  })   ! connection.on('ready',  function  ()  {          console.info('Connected');          exchange  =  connection.exchange('SOURCE:Exchange',  {  'type':  'topic',  durable:  true  },  function   ()  {                  var  queue  =  connection.queue('PROJECTION:Map',  {  durable:  false,  exclusive:  true  },                  function  ()  {                          console.info("Joined  Queue");                          queue.subscribe(function  (message,  headers,  deliveryInfo)  {                                  var  policyDetails  =  JSON.parse(message.data.toString());                                  io.sockets.emit('postcode',  policyDetails.Address.Postcode);                          });                          queue.bind(exchange.name,  'AddressDetailsSpecified');                  });                  queue.on('queueBindOk',  function  ()  {  console.info('Bound  queue  to  exchange');  });          });   ! });
  38. 38. Is it a silver bullet?
  39. 39. Lessons Learnt • Prefer simpler communication protocols • Messaging == Push == Transient, • HTTP == Pull == Permanent • Difficult to evolve Domain Events • Events as the system contract rob.knight
  40. 40. ha T u! Yo nk Tom Scott @tomwscott

×