Constantin Galbenu
  • Member for 5 years, 6 months
  • Last seen more than 1 year ago
How exactly should a CQRS Command be validated and transformed to a domain object?
Accepted answer
29 votes

The following answer is in the context of the CQRS style promoted by the cqrs.nu in which commands arrive directly on the aggregates. In this architectural style the application services are being ...

View answer
ES / CQRS concurrency handling
Accepted answer
25 votes

I sketched my rough understanding on how an ES / CQRS app should look like contextualized to a simplified banking use case (withdrawing money). This is the perfect example of an event sourced ...

View answer
In DDD, is a Domain Service essentially just a Facade and/or Mediator Pattern?
Accepted answer
16 votes

Domain services are best described by what they are not: they are neither Entities nor Aggregate roots they are not Value objects carry domain knowledge that doesn’t naturally fit only one Entity or ...

View answer
Can readmodel and writemodel inherit from Model for fields in DDD + CQRS?
9 votes

Sharing a base model is against everything that CQRS stands for. If your models (write and read) are 99% percent then it is a CRUD architecture painted to look like CQRS. You must split the write ...

View answer
DDD Injecting Services on Entity Methods Calls
8 votes

Is it within best practices of DDD and OOP to inject services on entity method calls? No, you should not inject anything inside your domain layer (this includes entities, value objects, factories and ...

View answer
Does reference by ID between Aggregates lead to an Anemic Domain Model?
Accepted answer
8 votes

Vaughn Vernon's recommendation is one of the best tactical rules that one should follow. If you really need to hold a reference to another aggregate root then you need to review your aggregate's ...

View answer
Where does business logic go that involves multiple aggregates?
Accepted answer
6 votes

The business logic that coordinates processes involving multiple Aggregates should stay in a Saga/Process manager. This does not mean that all the logic should stay there. No. Only the coordinating ...

View answer
How to design anti-corruption layer in DDD
Accepted answer
6 votes

An Anti-corruption layer is a class/ package/component that take as an input the external model and it produces the local model. For example, in a CQRS architecture, it can be implemented as a Saga: ...

View answer
How can I avoid a cross aggregate transaction?
6 votes

You need a process manager/saga that do exactly what you need without using transaction that spawn multiple aggregates. Basically that Saga would reserve the ticket right before the payment begins ...

View answer
CQRS with sub methods that are used in more than one place
Accepted answer
5 votes

What you have here is a problem of code reutilization. The CQRS commands should be simple, immutable, with behavior related to their own data. Their role is to express the intent of doing something ...

View answer
Can an aggregate only ever consume commands and produce events?
5 votes

aggregates consume commands and produce events: What is the foundation for this rule? In DDD, the Aggregates are the only one that are allowed to mutate the system state, so they are the only one ...

View answer
How to design classes in php in respository pattern?
Accepted answer
5 votes

The first thing that you should do is to split your monolith into multiple modules, one module per Bounded context. This is also the most important architectural decision that you will make. If you do ...

View answer
Using Event Sourced Aggregate Roots with the Specification Pattern
Accepted answer
5 votes

Repository is set up to get ARs by their ID from the event store. That should suffice. If you need to query a collection of ARs from the repository you should use a specially designed Read model. ...

View answer
Is it good practice to use entity objects as data transfer objects?
5 votes

It is actually a very bad idea. Martin Fowler has an article about Local DTOs. Long story short, DTO Pattern was used for transfering data outside the process, for example over the wire and not ...

View answer
DDD Domain Models and Business Logic
5 votes

This is a very broad question but I will try to give you an answer. ...there is some ambiguity with regard to the use of domain models and application services There is no ambiguity if you design ...

View answer
How to model domain events so that the denormalizers can fill highly denormalized read models
Accepted answer
4 votes

The domain events should contain the data that is required and owned by the Write model/the Aggregate. If the Readmodel may need additional data that is not strictly required by the Aggregate and the ...

View answer
Deconstructing monolith software bounded contexts for domain driven design
Accepted answer
4 votes

You should analyze all the differences in behavior from the departments in order to make the correct architectural decision. The simplest case is the one in which you make only a single product (a ...

View answer
DDD: How to work with entity variations?
Accepted answer
4 votes

The problem is that in general, in any application design, that there are 2 kinds of models: a write model and one or more read models. The classic application architecture style merges the two types ...

View answer
CQRS in Collaborative Domains
4 votes

Yes, you can have granular commands with CRUD also. That paragraph is not about the differences between CRUD and CQRS, but where you could use CQRS. In order to understand the differences you should ...

View answer
DDD - Application Gateway
Accepted answer
4 votes

This is outside the DDD concern. If you correctly identify the bounded contexts and the Aggregate boundaries, if your Domain layer is pure (no side effects) with no dependencies to Infrastructure or ...

View answer
How to handle child objects that need DB interaction for their business logic
4 votes

I would pass all the required information down as a method parameter in order to keep the Aggregate as clean as possible. class Customer { constructor(name, age) { this.name = name; this....

View answer
CQRS with an Event Log and without Event Sourcing
Accepted answer
3 votes

I can't find any authoritative answer between the difference between the two terms: "event log" and "event store". Martin Fowler uses both terms in this post but it's not clear if there is a ...

View answer
Event Sourcing and cross Aggregate validation
Accepted answer
3 votes

What you have here is inter-aggregate validation, possibly inter-bounded-context also. This is not a kind of validation that is done inside a single Aggregate, so this code && b....

View answer
Rehydrating Aggregates from a "snapshots" projection rather than the Event Store
3 votes

The main reason is performance. You could store a snapshot for every commit (commit = the events that are generated by a single command, usually only one event) but this is costly. Along the snapshot ...

View answer
How do I define a single generic method to apply events that are subtypes of a base class?
3 votes

Unfortunately Java does not support multiple dispatch but you can use reflection to call the appropriate method without breaking the Open close principle or introduce accidental dependency between ...

View answer
Do Value objects have behaviour?
3 votes

Anemia does not make sense in the context of Value objects, but in the context of Entities, especially Aggregates. However, Value objects can have some kinds of behavior (like formatting, conversions,...

View answer
Best way to access a logger across an application/website in PHP
3 votes

I personally like to use Dependency Injection. Here is some example: class MyClass { public function __constructor(\Psr\Log\LoggerInterface $logger) { $this->logger = $logger; } ...

View answer
Aren't Domain Driven Design/"hexagonal architecture" with real world constraints and the insistence on "non anemic model" contradictory?
2 votes

DDD/"hexagonal architecture" ... DDD doesn't enforce any specific architecture, you are free to choose whatever works for your application. The confusion comes from the book itself, where the ...

View answer
Cross-aggregate operations, use domain service or domain events?
Accepted answer
2 votes

First of all you need to identify the business rules and the consistency requirements for those rules. This leads to Aggregates' design. The Aggregate is the largest strong-consistency boundary. This ...

View answer
Event Sourcing CQRS and request events ending at Requested
Accepted answer
2 votes

In CQRS+ES there are domain events representing facts that are persisted instead of the flat state and commands that express the intent to do something that will result in zero or more facts. That ...

View answer