CQRS by Example
This book is 15% complete
Last updated on 2020-06-03
About the Book
Four years have passed since our first publication, we established what we think is a solid ground for DDD building blocks and Hexagonal Architecture. It is time to explore how to solve the limitations some projects may face at scale.
We think CQRS is the next natural step forward and we want to guide you through it.CQRS is usually discussed along with Event Sourcing, a pattern where application state is a projection of the Domain Events that happen through its lifetime. Event Sourcing relies on having a stream of Domain Events to reconstitute state. Something convenient for operations that modify the state of the application, known as Commands; however, querying the system requires some special mechanisms that aren't that trivial. We can say than in Event Sourced systems CQRS is mandatory in order to generate the required information to be able to query later, but the opposite isn't true. We can develop a CQRS system without Event Sourcing, so worry not, this book won't cover Event Sourcing.
In this book, we'll explore Hexagonal Architecture drawbacks, and we'll dive into CQRS by exploring plenty of real examples that you can use in your projects. Even though code examples are written in PHP, the patterns and techniques described in this book are applicable to any programming language and likely any paradigm you may be using. We can't thank you enough for purchasing this book and be an active contributor of Domain-Driven Design, Hexagonal Architecture, and CQRS!
- First Book: Domain-Driven Design in PHP
- DDD acceptance has rapidly grown
- Second Book: CQRS by Example
- Who Should Read This Book
- Summary of Chapters
- Code, Typos, and Examples
About the Authors
- Carlos Buenosvinos
- Christian Soronellas
- Keyvan Akbary
CQRS and Domain-Driven Design
- What is all the fuzz about?
- Why Domain-Driven Design Matters
- The Three Pillars of Domain-Driven Design
- Considering Domain-Driven Design
- The Tricky Parts
A Journey Towards CQRS
- Introducing Cheeper, a Twitter Clone
- Typical Architectural Styles
- A brief analysis
Anatomy of CQRS
- Hexagonal Architecture limitations
- Command-Query Separation
- The Command Side
- The Query Side
- Syncing the Command and Query sides
Command Side and the Write Model
- Command Handlers
- Command Bus
Query Side and the Read Models
- Query Handlers
- Query Bus
Synchronizing the Write and Read Models
- Multiple Read Models
- No Synchronizing
- Optimizing Projections
- CQRS Heuristics
- Event Sourcing
- My Write Model as another Read Model
- Final Words
- The End
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.