Hi.
I’m doing investigation of using CQRS+DDD+Event Store for one project.
And I couldn’t find answer on the following question: how
Specification pattern can be used in such configuration? There is
example of using Specification with Repository in book “Domain-Driven
Design: Tackling Complexity in the Heart of Software”, but such
approach is OK only if we use RDBMS for domain, and it doesn’t work if
we use Event Store, because of we can only get AR from Repository by
ID.
This question looks like issue of uniqueness that is discussed on
http://groups.google.com/group/dddcqrs/browse_thread/thread/745e86b5078c32e7
and
http://groups.google.com/group/dddcqrs/browse_thread/thread/69496d381d9afb76,
but IMHO issue with Specification is more common. So I see the
following ways of solutions for it:
1. Repository can ask reporting tables for getting list of IDs of ARs
that can satisfy given specification. I don’t like this way because of
coupling command part with query part. Service(s) can be used for
isolation such coupling (for example SpecificationService with method
Collection<UUID> findSatisfied(Specification spec), but I feel that it
is something wrong with it.
2. Repository loads all ARs of given type and pass them to given
specification. I know that it is awful from performance point of view.
3. Find IDs of required ARs on client side and pass them with command
in domain.
What from suggested solutions is good enough from your point of view?
Are there other solutions for this issue? Or maybe I’m trying to solve
it in wrong way?
Thanks.