Some notes on the DDD/CQRS Course
Marco Franssen /
2 min read • 306 words
In this blog post I work out some of the notes I made in Greg Young’s DDD/CQRS course in Krakow Poland.
In Domain Driven Design there are some important things to think about. In DDD we make a difference in the following components.
- Aggregate Roots
- Entities
- Value Objects
An Aggregate root is a set of multiple things that belong to each other. The aggregate should have a name that describes the whole.
To come to a domain driven design you should take the following steps:
- Denormalization
- Transactions –> try to avoid
- Domain service consistency –> try to avoid
- Use soft links to learn it the right way
When applying the above you should mention the bullets below when applying them:
- Remove the bidirectional relations
- Define your aggregates
- Make sure operations only affect one aggregate at a time
- Put methods where the state is encapsulated / where the data is changed (objects should change their own state)
- A command may only mutate state and has always a void return value
- A Query may only expose state and can’t be a void return value
- Avoid distributed transactions to have good scalability
Even without transactions you can provide consistency in your systems. We can do this by merging. You can do this with the following code-snippet. Notice the recursive call in the catch clause.