1 / 75

CQRS:

CQRS:. Crack for Architecture Addicts… -or- …An Idea Who’s Time Has Come?. Thanks for celebrating 10 years of the .NET Community with INETA. Happy Birthday!.

travis
Download Presentation

CQRS:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CQRS: Crack for Architecture Addicts… -or- …An Idea Who’s Time Has Come?

  2. Thanks for celebrating 10 years of the .NET Community with INETA Happy Birthday!

  3. Follow us at @ineta. Tweet using the hashtag#INETA10 for a chance to win a prize in our daily random drawing throughout February. Tweet for Prizes

  4. Post your User Group photo and send us a link (at birthday@ineta.org) to be entered in the User Group weekly random drawing during February. We’ll post the link on the birthday page. Send Your Photo to Win

  5. GrapeCity is putting together a video featuring user group leaders. See the February newsletter for details and send your video clip to be included. Birthday Video http://ineta.org/newsletters/2012_02.htm

  6. INETA's birthday gift to you! A complimentary one year subscription to Code Magazine is available to all new subscribing U. S. Members. Go to www.codemag.com/subscribe/ineta10 to receive your free subscription! Special offer from CODE Magazine

  7. Thank you Platinum Sponsors http://www.componentone.com

  8. Thank you Platinum Sponsors http://www.esri.com

  9. Thank you Platinum Sponsors http://www.infragistics.com

  10. Thank you Platinum Sponsors http://www.telerik.com

  11. Thank you Gold and Silver Sponsors http://www.red-gate.com http://www.grapecity.com

  12. Thank you Donation Sponsors oreilly.com grapecity.com typemock.com

  13. Thank you Donation Sponsors winconnections.com code-magazine.com ssware.com

  14. About INETA INETA provides structured, peer-based organizational, educational, and promotional support to the growing worldwide community of Microsoft® .NET user groups. http://ineta.org

  15. INETA Programs - Community Speakers program- Virtual Groups and Speakers- Community Champions - INETA Live!- Outreach and recognition for user groups- Offers from sponsors for groups and members http://ineta.org

  16. INETA Newsletter Keep up with news on programs, training, special events and other happenings in the world of the .NET community.Visit the link on the archive page and enter your email address to be added to the mailing list. http://ineta.org/newsletters

  17. Community Speakers Program Anyone can register to become part of the program. Group leaders can find speakers as often as you like. http://ineta.org/Speakers/

  18. INETA Live Learn something new with the community presentation recordings available now on INETA Live! http://live.ineta.org/

  19. Community Champions Tell us what you do to support the .NET Community and get recognized. http://inetachamps.com

  20. Get Your Code On and Win Win a scholarship and paid travel to either DevConnections in Las Vegas or TechEd in Orlando with the Component Code Challenge. http://ineta.org/CodeChallenge

  21. Special Offers for INETAMembers and Groups http://ineta.org/offers

  22. CQRS: Crack for Architecture Addicts… -or- …An Idea Who’s Time Has Come?

  23. Do I Suck? http://speakerrate.com/talks/9298

  24. Who am I? • …and why should you care? • Steve Bohlen • I Read Books + Write Software • vs. “Read Software + Write Books”  • Blog, Screencast, Speak, Share, Learn

  25. Nearly 20 years developing software LISP, Delphi, C/C++, VB, VB.NET, C#, Ruby Senior Engineer Springsource/VMware Co-Founder, NYC Alt.Net User Group http://nyalt.net • Co-Organizer, NYC DDD User Group • http://dddnyc.org Contributor: various OSS projects Nhibernatehttp://www.nhforge.org • NDbUnithttp://www.googlecode.com/ndbunit • Spring.NET http://www.springframework.net blog: http://blog.unhandled-exceptions.com e-mail: sbohlen@gmail.com twitter: @sbohlen

  26. Beta Presentation

  27. Opinions Ahead

  28. Agenda • What’s wrong with Traditional Application Architecture? • What is CQRS? • Commands and Events • Persistence • Understanding Event Sourcing • Exploring a simple CQRS sample app • Exploring a comprehensive CQRS sample app (?) • Resources to Learn more • Q+A

  29. What’s wrong withTraditional Application Architecture?

  30. Traditional Architecture

  31. Traditional Architecture Client Return DTO ACK Returned LAN/WAN Request DTO Command Remote Services Application Services Domain Object Domain Object Domain Object Domain Object RDBMS

  32. Application Design Pain Points • Scalability of System is by larger and larger RDBMS • Surprise, surprise!  • Persistence means ‘save the Current State’ of the domain model • Query concerns are at odds with Transactional concerns • 1NF vs. 3NF • more…

  33. Domain Modeling Pain Points • Business Rules only exist in user’s heads • Converting Domain Objects to DTOs (and back again!) • Domain Object Persistence • Lazy vs. Eager Fetching • Optimizing Domain for efficient Queries • Setter/Getter Anti-Pattern • Tests are (often) brittle • more…

  34. Business Pain Points • Must know what business questions we want to ask up front • Optimizing for Queries and Optimzing for Transactions are tied together (and expensive) • Evolving Requirements is hard/expensive • more…

  35. Self-Delusion • One model can be made to efficiently serve two (or more!) different masters • Competing optimization needs of Queries and the Transactions can be efficiently balanced • Getters/Setters are a necessary evil • Persisting State is the only way to think about the problem

  36. What is CQRS?

  37. Command-Query Separation Command-Query Separation (CQS) 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. -Bertrand Meyer, designing the Eiffel language

  38. Interface Segregation Principle

  39. Command-QueryResponsibility Segregation • The CQS principles applied to your domain modeling and system architecture • Enable each element of your architecture to be optimized for a single responsibility • Decomposition for your architecture rather than just for your objects

  40. Slicing and Dicing our Architecture Client Return DTO ACK Returned LAN/WAN Request DTO Command Client Remote Services Server Application Services Domain Object Domain Object Domain Object Domain Object RDBMS Read Write

  41. Refactoring our Architecture Client Return DTO ACK Returned LAN/WAN Request DTO Command Remote Services Remote Services Remote Services Application Services Application Services Domain Object Domain Object Domain Object Domain Object Light-Weight Query Services Persistence RDBMS Persistence Eventually Read Write

  42. Scaling our Systems Write Read C A P CAP Theorem: onsistency, vailability, artition-Tolerance; pick any two! A P C

  43. About “Eventual Consistency” • Domain Experts deal in ‘stale’ data all the time • Edit screens, Reports, Analysis, OLAP • ‘Staleness’ is often already implicitly in our systems • Caching, Optimistic Concurrency, and more • Eventual Consistency is making that ‘staleness’ an explicit (and acknowledged) fact in the system • Language matters: say staleand oldernot out-of-dateor inconsistent • Opportunity to actually discuss ‘how stale is OK?’ • Often we make data stale without this discussion at all

  44. Commands and Events in CQRS

  45. Refresher: the Aggregate Root Pattern Aggregate Boundary Aggregate Boundary Entity1 Entity1 Entity2 Entity2 ValueObject1 Entity3 Aggregate Boundary ValueObject1 Entity1 ValueObject2 ValueObject1 ValueObject2

More Related