Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aggregates in CQRS

What are aggregates and how are they used in CQRS (Command-Query-Responsibility-Segregation) and ES (Event-Sourcing)? I'm new to this kind of architecture, and I'd be really happy if someone could please explain this to me. Thanks!

like image 557
shmuli Avatar asked Dec 05 '13 05:12

shmuli


1 Answers

First I'd like to quote Martin Fowler's blog post on CQRS and note that Aggregates are rather related to Domain Driven Design then to CQRS.

CQRS naturally fits with some other architectural patterns.

  • As we move away from a single representation that we interact with via CRUD, we can easily move to a task-based UI.
  • Interacting with the command-model naturally falls into commands or events, which meshes well with Event Sourcing.
  • Having separate models raises questions about how hard to keep those models consistent, which raises the likelihood of using eventual consistency.
  • For many domains, much of the logic is needed when you're updating, so it may make sense to use EagerReadDerivation to simplify your query-side models.
  • CQRS is suited to complex domains, the kind that also benefit from Domain-Driven Design.

In terms of Domain-Driven Design Aggregate is a logical group of Entities and Value Objects that are treated as a single unit (OOP, Composition). Aggregate Root is a single one Entity that all others are bound to.

like image 70
Ilya Palkin Avatar answered Oct 15 '22 12:10

Ilya Palkin