Hot answers tagged

89 votes
Accepted

Better to have 2 methods with clear meaning, or just 1 dual use method?

You seem to suggest that the complexity of an interface is measured by the number of elements it has (methods, in this case). Many would argue that having to remember that the charge method can be ...
MichelHenrich's user avatar
35 votes
Accepted

Should CQRS Command perform a Query?

Let's start with a short review of the problem-space here. The fundamental benefit of adopting a CQRS pattern is to solve/simplify your problem domain by reducing the interleaving and leakage that ...
user3347715's user avatar
  • 3,144
33 votes
Accepted

How does a REST API fit for a command/action based domain?

In the first case (shut-down of VMs), I'd consider none of the OP alternatives RESTful. Granted, if you use the Richardson maturity model as a yardstick, they are both leve 2 APIs because they use ...
Mark Seemann's user avatar
  • 3,900
30 votes
Accepted

How exactly should a CQRS Command be validated and transformed to a domain object?

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 ...
Constantin Galbenu's user avatar
28 votes

Better to have 2 methods with clear meaning, or just 1 dual use method?

IMO, replacing getBalance() with charge(0) across your application isn't a simplification. Yes it is fewer lines, but it obfuscates the meaning of the charge() method, which could potentially cause ...
Matt Dalzell's user avatar
26 votes
Accepted

ES / CQRS concurrency handling

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 ...
Constantin Galbenu's user avatar
23 votes
Accepted

Isn't CQRS overengineering?

Is CQRS a relatively complicated and costly pattern ? Yes. Is it over-engineering ? Absolutely not. In the original article where Martin Fowler talks about CQRS you can see a lot of warnings about not ...
Machado's user avatar
  • 4,110
21 votes
Accepted

Event sourcing, replaying and versioning

First, it is important to understand and be able to leverage the difference between Commands and Events. As this question succinctly points out, Commands are things we would like to happen, and ...
theMayer's user avatar
  • 648
19 votes
Accepted

When using DDD and CRQS, should be exactly one event per command?

Since you tagged your question with "CQRS", I guess you mean events in a "CQRS & Event Sourcing" context, like it is described here. In this tutorial, the difference between ...
Doc Brown's user avatar
  • 206k
19 votes
Accepted

Should I use a command or an event?

In principle, a command describes a request that is to be executed, whereas an event describes something that has happened: A command requires some action to be performed by a processor, and this ...
Christophe's user avatar
  • 76.8k
18 votes
Accepted

How to implement a process manager in event sourcing

Review what Rinat Abdullin wrote about evolving business process. In particular, notice his recommendation for developing a business process in a fast changing environment -- a process manager is "...
VoiceOfUnreason's user avatar
17 votes
Accepted

Are CQRS and Hexagonal Architecture incompatible?

This is like asking if you can use utensils to eat ice cream. (Yes you can. I recommend a spoon.) CQRS asks you not to mix together the complexity needed to perform queries with the complexity needed ...
candied_orange's user avatar
16 votes

Rehydrating Aggregates from a "snapshots" projection rather than the Event Store

What I'm not super clear on is why you would ever rehydrate your Aggregates from the Event Store itself. Because the "events" are the book of record. If projecting changes to "read" databases is ...
VoiceOfUnreason's user avatar
15 votes

In CQRS/ES, can a command create another command?

In retrospect, I think I was complicating the issue. In general, commands should either throw an exception or raise one or more events. If I could summarise the architecture of Event Sourcing it ...
magnus's user avatar
  • 674
15 votes
Accepted

Can CQRS pattern exist without mediator pattern?

Command Query Responsibility Separation (CQRS) separates reading and writing into two different models. A "conventional" architecture looks like this: A CQRS architecture looks like this: Notice ...
Robert Harvey's user avatar
14 votes
Accepted

How do I deal with side effects in Event Sourcing?

How do I deal with side effects in Event Sourcing? Short version: the domain model doesn't perform side effects. It tracks them. Side effects are performed using a port that connects to the ...
VoiceOfUnreason's user avatar
13 votes

Better to have 2 methods with clear meaning, or just 1 dual use method?

It's important to remember that your code should be self-documenting. When I call charge(x), I expect x to be charged. Information about balance is secondary. What's more, I may not know how charge() ...
David says Reinstate Monica's user avatar
12 votes

Domain Services vs. Factories vs. Aggregate Roots

After dealing with DDD for months now, I'm still confused about the general purposes of domain services, factories and aggregate roots in relation to each other, e.g. where they overlap in their ...
VoiceOfUnreason's user avatar
11 votes

When using DDD and CRQS, should be exactly one event per command?

One command can raise multiple events. It is simply logical conclusion of one fact : Composite command exists. Lets say you have two commands, each raising an event. Then, you create a composite ...
Euphoric's user avatar
  • 37.3k
11 votes

When using DDD and CRQS, should be exactly one event per command?

Usually one command will lead to one event. But in some cases it can also be more than one, it depends on your implementation. Either your command calls other commands and each of them fire own ...
synthomat's user avatar
  • 256
11 votes

How does a REST API fit for a command/action based domain?

Shutting down a VM through a REST interface This is actually a somewhat famous example, put forth by Tim Bray in 2009. Roy Fielding, discussing the problem, shared this observation: I personally ...
VoiceOfUnreason's user avatar
11 votes

DDD, CQRS, ES - is it worth it or it just waste of time?

Well they are three separate things and they are real things not just buzz words. But.... Domain Driven Design. I've seen this used quiet commonly now, at least in a 'lite' fashion. I think it does ...
Ewan's user avatar
  • 74.7k
11 votes

Zero argument constructors and Always Valid entities

Before I address the kinds of considerations that go into object creation, let's first address the motivation behind your question: the phrase "Always Valid Domain Entities". This phrase is, at best, ...
user3347715's user avatar
  • 3,144
11 votes
Accepted

CQRS and GraphQL

Software engineering is always a series of trade-offs. You have to give up something to get something else. The unfortunate reality is that we don't always have a full picture of what the impacts ...
Berin Loritsch's user avatar
10 votes

How exactly should a CQRS Command be validated and transformed to a domain object?

One fundamental premise of DDD is that domain models validate themselves. This is a critical concept because it elevates your domain as the responsible party for making sure your business rules are ...
user3347715's user avatar
  • 3,144
9 votes
Accepted

Where does business logic fit in the Command Query Responsibility Segregation Pattern?

Your example is not a mutator, command or query; it's simply a function. You would need to know today's date to make the calculation, but calling that a query is stretching things a bit. CQRS is an ...
Robert Harvey's user avatar
9 votes
Accepted

CQRS without DDD and without (or with?) ES - what is write model and what is read model?

Greg Young (2010) CQRS is simply the creation of two objects where there was previously only one. If you think in terms of Bertrand Meyer's Command Query Separation, you can think of the model as ...
VoiceOfUnreason's user avatar
9 votes

Can readmodel and writemodel inherit from Model for fields in DDD + CQRS?

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 ...
Constantin Galbenu's user avatar
9 votes
Accepted

CQRS-Event Sourcing: how to process events in the expected order inside the read model

The infrastructure for the event sourcing is an event store which saves the events as documents inside a MongoDB collection and then publish a corresponding message to a service bus, so that with a ...
VoiceOfUnreason's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible