classic vs cqrs architecture
classic vs cqrs architecture
LIST
classic vs cqrs architecture
Code snippets from GregYoung 8 CQRS Class - YouTube public class DeactivateInventoryItemCommand { public readonly Guid InventoryItemId; public readonly string Comment; public DeactivateInventoryItemCommand (Guid id, string comment) { InventoryItemId = id; Comment = comment; } void DeactivateInventoryItem(Guid, string comment) CommandHandler contains no logic, logic is in domain object delegates to domain object public class DeactivateInventoryItemHandler : Handles<DeactivateInventoryItem> { public DeactivateInventoryItemHandler(InventoryItemRepository rep){} void Handle(DeactivateInventoryItem cmd) { var item = repository.GetById(cmd.Id); item.Deactivate(cmd.Comment); } } Application Services cross-cutting concerns (logging, authentication)...
(I don’t remember the source! If anyone can recognise it, let me know please!) Domain Model - Architecture OO model Aggregate - entities consistent (business rules / invariants) - persistence (one repo per aggregate) - guard access Domain Services Aggregate vs Service Repo <= Domain Service handles persistence for an aggregate Antipattern: Anemic Models
high level CQRS and Event sourcing client commands write / domain events read model dtos client
Code snippets from GregYoung 8 CQRS Class - YouTube public class DeactivateInventoryItemCommand { public readonly Guid InventoryItemId; public readonly string Comment; public DeactivateInventoryItemCommand (Guid id, string comment) { InventoryItemId = id; Comment = comment; } void DeactivateInventoryItem(Guid, string comment) CommandHandler contains no logic, logic is in domain object delegates to domain object public class DeactivateInventoryItemHandler : Handles<DeactivateInventoryItem> { public DeactivateInventoryItemHandler(InventoryItemRepository rep){} void Handle(DeactivateInventoryItem cmd) { var item = repository.GetById(cmd.Id); item....
GregYoung 8 CQRS Class ( https://www.youtube.com/watch?v=whCk1Q87_ZI ) Code snippets from GregYoung 8 CQRS Class - YouTube original Code snippets from GregYoung 8 CQRS Class - YouTube
Course: CQRS in Practice (https://app.pluralsight.com/library/courses/cqrs-in-practice) CQRS & Onion Architecture Map CQRS & Onion Architecture where do C, Q, E belong? Map where do C, Q, E belong? Where to put Command Handlers Map Where to put Command Handlers Command reuse -> domain service Map Command reuse -> domain service Domain Service called for duplicate code Projections Map Choosing projection type A - database triggers...
Greg Young — A Decade of DDD, CQRS, Event Sourcing ( https://www.youtube.com/watch?v=LDW0QWie21s )
Greg Young - CQRS and Event Sourcing - Code on the Beach 2014 https://www.youtube.com/watch?v=JHGkaShoyNs Notes: test without getters: 3:28:20 / 6:31:00 don’t care about state if I call ‘Deactivate’ twice, I get an exception that’s the invariant VERSIONING Event Versioning: 4:24:22 / 6:31:00 add both methods in aggregate upcasting old to new event When do we need to versionize events? -> when they were written to production dev? just throw away your local event log...
Introducing EventStorming An act of Deliberate Collective Learning (https://leanpub.com/introducing_eventstorming) Preface - 25% About this book Who is this book for Notation Acknowledgments How to read this book Version 1. What does EventStorming look like? - 85% Challenging corporate processes Kicking off a startup Designing a new feature for a web app Quick EventStorming in Avanscoperta A deep dive into problem space 2. A closer look to the problem space - 80% Complexity in a nutshell, or less Organization silos Hierarchy The shape of the problem...