A simple an accessible CQS/CQRS set of libraries.
- Illustrate the CQS/CQRS usages in a simple and clear manner, even for the beginner
- Provide a "ready to use" seed that people can use as it is or really easily modify for their own usage
- Show how CQRS can allow for total framework independence. AKA : Moving you domain logic from Spring to dropwizard IS simple.
- Illustrate and insist on the fact that different flavors of CQS/CQRS exist. AKA: You probably do not need event sourcing right now and even a really simple CQS split will greatly help you in your unit testing. (Refer to the link provided for more infos on that).
During my research on the subject, I could not find a simple enough Java example that would help me fully understand the CQS/CQRS concepts. Not many implementation exist or, really often, they take a highly generalized, highly functional and/or straight to event sourcing approach. My experience is that those are terrible to read for the beginner and confuse more than illustrate the underlying concepts.
- No hidden magic, no weird annotations, no over-engineered generic abstract classes, no dark voodoo.
- "Repetition is better than the wrong abstraction" - Sandi Metz.
- "Get simple or die trying" - 50 cents, the untold quotes.
- "You use libraries. But frameworks use you"
- There might be better ways to do it. Still, nobody will be fired for doing it this way.
- Say goodbye to service layers and lasagna code
- An external world proof code base
- Finally! freedom on the read side, a word without the dictatorship of Mappers (You might never come back)
- Testability by use case
- Amazing decoupling
- Better traceability of what happens on your system
- Easy handling of specifications change, especially when it come to side effects
More classes really, but they should be way simpler to deal with
I use this architecture in production, not on a "let's code twitter in 30 seconds" toy project but in a payroll app people rely on to receive their money. They are pretty unforgiving audience and did not complain so far. Once understood, I find this type of architecture to be a delight to work with and to offer a flexibility I was herdly finding in my projects previously.
Do not to take my word on it. Take it for a spin.
- Looks at the linked presentations / slides.
- Checkout the cqrs-api project. As an exercise, add unit tests and a decorator for each of the command/query buses. That should give you an idea of what happens.
- Looks at the happy-neighbourhood domain code.
- Look at the various frameworks integrations (only Spring is available so far).
- Add your own spices to it.
Those great presentations :
https://speakerdeck.com/lilobase/ddd-and-cqrs-php-tour-2018
https://www.slideshare.net/rosstuck/command-bus-to-awesome-town
Alistair in the hexagone: https://www.youtube.com/watch?v=th4AgBcrEHA
Models & Service Layers; Hemoglobin & Hobgoblins: https://www.youtube.com/watch?v=ajhqScWECMo
To be done but in the meantime
- hexagonal architecture
- Implementing Domain Driven Design
More to come...
If you are a beginner, you should definitely stay away from frameworks. Don't even get me started on Lagom.