Your SlideShare is downloading. ×
0
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Introduction to CQRS and DDDD
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to CQRS and DDDD

284

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
284
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Warm-up
    DDD Building Blocks
    Classic Architecture
    Database Normalization
    Scaling Reads
    Scaling Writes
    The Single Source of Truth
    Breaking Free
  • Transcript

    • 1. EXORCISM “THE PRACTICE OF EVICTING DEMONS OR OTHER SPIRITUAL ENTITIES FROM A PERSON OR AN AREA THEY ARE BELIEVED TO HAVE POSSESSED”
    • 2. CQRS DISTRIBUTED DOMAIN DRIVEN DESIGN
    • 3. Classic Architecture Client executes interactors Interactor modifies data and returns ViewModel
    • 4. Step 1: CQS Command/Query segregation Commands - write data, void Queries - read data
    • 5. Step 1: CQS public class SubmitAction : Interactor { public ShowLeadViewModel Execute(LeadActionDTO action) { var lead = ExecuteLeadAction(action); var viewModel = BuildViewModel(lead); return viewModel; } }
    • 6. Step 1: CQS public class SubmitAction : Interactor { public void Execute(LeadActionDTO action) { ExecuteLeadAction(action); } public ShowLeadViewModel GetLeadInfo(long id) { var lead = GetLead(id); var viewModel = BuildViewModel(lead); return viewModel; } }
    • 7. Step 1: CQS public class SubmitAction : Interactor { public void Execute(LeadActionDTO action) { ExecuteLeadAction(action); } public ShowLeadViewModel GetLeadInfo(long id) { return GetLeadViewModel(id); } }
    • 8. Step 1: CQS Separated Query/Command logic Commands are executed asynchronously Queries are executed though a thin read layer
    • 9. Normalization: 3NF vs. 1NF lead_id status_id queue_id contact_id campaign_ id assigned_t o_id 1043 1 2 241734 54 108 1044 3 5 241771 78 109 lead_id status queue contact_n ame campaign assigned_t o 1043 New Wait Yau Siong 1043 Contacted Converted Dimas Wijaya Saraya [03SEP2012] Gunggo_C A [060512] Alex Delors Mona Barbara
    • 10. Step 2 Write model: 3NF Read model: 1NF
    • 11. Step 2
    • 12. Step 2: Events
    • 13. Step 2: Events Multiple projections Scalable reads Decoupled storage mechanism RDMBS, Document store, Key/Value store, plain files (local or S3), Sharepoint List, Lucene, Cloud Search No need for NHibernate Profiler licenses
    • 14. Step 2: Events
    • 15. No reliable source of truth.
    • 16. Step 3
    • 17. Step 3: Events History
    • 18. Step 3: Events History Every data change is logged Reliable source of truth Read model can be regenerated anytime Write model can be regenerated anytime
    • 19. Step 3: Events History
    • 20. Writes are not scalable.
    • 21. Step 4
    • 22. Step 4 var lead1 = { “leadId”: 15423, “customer_id”: “zubby@bubby.com”, “events”: [ { “type”: “lead_created”, “data”: {…}, “date”: “20131216T1242” }, { “type”: “lead_assigned”, “data”: {…}, “date”: “20131216T1342” }, { “type”: “activity_created”, “data”: {…}, “date”: “20131216T1432” }, { “type”: “new_lead_event”, “data”: {…}, “date”: “20131216T1522” }, { “type”: “activity_created”, “data”: {…}, “date”: “20131216T1432” } ] }
    • 23. Step 4
    • 24. Step 4: Event Sourcing
    • 25. Step 4: Event Sourcing Infinitely scalable reads Infinitely scalable writes Audit data New business insights form past data Replay events for debugging and analysis Retroactive logic changes (=bug fixes) Lightweight backups NoSQL No deadlocks No DBA CHEAP!!!!!
    • 26. CQRS Commands Events Event Store ViewModels / Projections
    • 27. Questions?
    • 28. DDD: Building Blocks Domain Driven Design Entity Aggregate Repository
    • 29. DDD: Aggregate shoppingCart = { “id”: 1234, “items”: [{ { “product_id”: 123, “amount”: 1, “price”: 10}, { “product_id”: 123, “amount”: 1, “price”: 10} }] }

    ×