I get where this is coming from, and I don't even disagree, but I think there is a blurry line between CQRS/CQS the concept and an implementation of command processing. The former, as you point out, doesn't lend itself towards a framework any more than the visitor pattern, but the latter certainly does.
In my view, a lot of the discussion around the notion of "why are you building frameworks when this is so simple it doesn't require one" really muddies the water. If you want to build a system which relies on command processing as an embodiment of CQRS (or for any other reason), you definitely need a framework, even if it just ends up delegating to WCF, TPL, F#'s message box, or something like that. It makes no sense to reinvent command transports, dispatchers, routers, or other EIP-style messaging components necessary to support such a system over the long haul.Maybe the nomenclature for such a system deserves more thought.
http://www.dofactory.com/Patterns/Patterns.aspx
Tom
Typed on a mobile
Quite simply, creating a framework tool for CQRS is like trying to
create a tool for SRP or one of the SOLID principles.
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software. It is a collection of software libraries providing a defined application programming interface (API).
Frameworks contain key distinguishing features that separate them from normal libraries:
- inversion of control
- In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.[1]
- default behavior
- A framework has a default behavior. This default behavior must actually be some useful behavior and not a series of no-ops.
- extensibility
- A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.
- non-modifiable framework code
- The framework code, in general, is not allowed to be modified. Users can extend the framework, but not modify its code.
The designers of software frameworks aim to facilitate software development by allowing designers and programmers to devote their time to meeting software requirements rather than dealing with the more standard low-level details of providing a working system, thereby reducing overall development time
Quite simply, creating a framework tool for CQRS is like trying to
create a tool for SRP or one of the SOLID principles.
Just because you can create a framework doesnt mean you should. Of
course scritchy is a framework, but it doesnt make it a CQRS
framework.
scritchy (or any so-called CQRS framework) canNOT separate command
operations from the query operations in a business domain. The
separation is a domain exercise.
Just because a framework provides a mechanism to handle event sourcing
and infrastructure to publish events does NOT make it a CQRS
framework.
Event sourcing is orthogonal to CQRS. Event publishing is orthogonal
to CQRS.
That said, if your implementing a CQRS architecture style into your
solution, then you will likely want to leverage those separate
concepts. But those concepts are orthogonal to CQRS.
There are plenty of "event sourcing" frameworks out there (Jonathon
Oliver - https://github.com/joliver/EventStore ). There are plenty of
"enterprise service bus" frameworks (Udi - NServiceBus).
My community concern is the risk of watching a version of CQRS become
CQRS-lite .... the equivelant of DDD-Lite (a DDD anti-pattern).
No one is discouraging you from letting your imagination run wild. If
you want to play with playmobil toys, by all means do so. Others,
including myself, have built so-called CQRS frameworks only to realize
it was a mistake. The semantics are important. Getting the words right
is important (lessons learned from TDD to BDD).
> I do not intend to make Scritchy a pars pro toto for CQRS, I never claimed
> it was the only way to do CQRS. My only single intent is getting the CQRS
> architecture out of it's ivory tower, because it is IMO an elegant approach
> to a common problem.
CQRS is hardly in an ivory tower. No framework tool is need to
separate command from queries. Its a domain and system level problem.
Have you had an opportunity to attend any of Greg Youngs online
sessions? If not, he makes it pretty clear how simple it is to apply
and emphasizes that one does not need a framework tool.
> According to your opinion I would have to say:
>
> "Scritchy is a software framework that contains an event store and
> a command bus, and you can use it to develop an application CQRS style."
Nope, never said that nor implied it.
> > No one is discouraging you from letting your imagination run wild. If
> > you want to play with playmobil toys, by all means do so. Others,
> > including myself, have built so-called CQRS frameworks only to realize
> > it was a mistake. The semantics are important. Getting the words right
> > is important (lessons learned from TDD to BDD).
>
> [Sarcastic mode] Alluding on the playing part, that must have required a
> really brilliant and creative mind. I am grateful to finally have a chat
> with somebody who possesses the absolute truth on life, the universe and
> all things semantic. [/Sarcastic mode]
>
Sarcasm aside (I assume your originial LEGO vs Playmobil comment was
sarcastic too) , your missing my point.
To be clear, I never defined CQRS. Greg Young (and Udi) did. My intent
is to simply reiterate their definition. You can choose to redine that
message if you want, but you should probably start calling it
something different. Getting the words right is very important. Much
like TDD was never intended to be about "testing".
There is a difference between CQS and CQRS. Trying to equate the two at the same level does not make much sense to me. What kind of programming principle is there in having a model for reads distinct from a model for writes? For one, it breaks the abstraction principle and DRY. So this principles are replaced by something else, what else? I would say, availability and performance.
Cheers,
Nuno
For the record, I should think that the community finds your zeal for the purity of the design concepts to be commendable. Seems that you hit it on the nail by asking what we are talking about; CQRS as a concept or as an architecture. It would be unfortunate to have CQRS popularized as an overloaded term which inadvertantly includes other, "orthogonal", patterns such as event sourcing, for example.
I get the sense that you want to keep things separate, as their conceptual nature implies. So, for naming a framework, perhaps one should think of giving the entire solution a proper name. I immediately think of frameworks named like Spring, and Sharp. They're a combination of technologies and patterns.
Sent from my Windows Phone
From: Dennis
Sent: 11/15/2011 5:24 PM
To: DDD/CQRS
Subject: [DDD/CQRS] CQRS is NOT a framework nor does it need one
CQS deals with
the separation at the method level. CQRS deals with the separation at
the object level. " There are 2 objects where there was one" Greg
Young.
IMHO, the concerns around CAP are embodied in the entire DDD as a theory of design.
Just look at the problem statement around the Aggregate pattern. Two distinct Aggregates can be potentially eventually consistent with each other. The "trick" is remove eventually consistency at this level is by understanding that the set of facts maintained by each do not overlap (DRY).
Cheers,
Nuno
On Nov 16, 2011, at 9:28 PM, Dennis wrote:
My primary point is CQRS is way of thinking about the domain (much
like DDD).
Aggregates only hold state involved in invariants.
Aggregates only hold state involved in invariants.
* Explicit separation of commands from queries. Its a domain exercise,
not a coding exercise.
* More of focus on messages (commands, events & queries)
You talked about it being something different to DDD with its own set of principles and practices. Something I never heard none of them stating.
Sent from my iPhone
And yes, one can use CQRS without DDD. It has been for a long time.
Udi says it quite clearly. One use case, one command, one Aggregate method, one transaction. At least he used to.
If you find that you need more then one transaction to perform a use case, then one is missing some concepts.
If you find that multiple use cases are interfering with each other to the point where an Aggregate becomes unusable the transaction boundary needs to be reduced. Hence you may need an Aggregate that captures that specific use case and capture the transaction as a long running business process.
You keep on doing in the drum-buffer-rope of design protecting the weakest links as they are found during performance testing. Otherwise you may end up with feeling the pipe with excessive inter aggregate messaging. This might be or not a problem depending on the network infrastructure.
Sent from my iPhone
Sent from my iPhone
CQRS is its own principle. I disagree (repeating) that CQRS is a
pattern. CQRS is a principle. Its orthogonal to DDD, ES, EDA etc
Seems odd to me since CQS is referred to as a principle.
Im actually harping on both.
Those things compliment each other but they are not necessary
to apply CQRS.
individuals seem to be encompassing CQRS to mean you are doing ES
To cut a long story short and avoiding the semantics around what is a principle or a pattern.
If CQRS stated that: "Every object should not have methods changing state and methods returning data"!
This would be a principle.
Now CQRS is not described like that. Sorry. But is not.
At the model level if a there was a CQRS principle it would be: "Every model should not have objects changing state and objects returning data"!
Again its is not described like that.
I don't have the time now to go deeper why it is not described like that. To put it succinctly:
CQRS was born out of a very common problem. The impedance mismatch between the object structures necessary to process data efficiently and the object structures necessary to query / observe data efficiently. I've posted awhile ago about the driving forces of CQRS in my context.
Cheers,
Nuno
If there was a CQRS principle it would be something like this:
At the object level
"Every object should either have methods that return data or change state, not both"!
At the model level
"Every model should either have objects that return data or that change state, not both"!
CQRS is not described like that in any way since many people would probably disagree, myself included. This because it rises problems that are beyond the scope of this thread. Instead it is described as a Pattern solving a particular set of problems. One important one I described in the previous post.
Cheers,
Nuno
> How are those descriptions not rules? Seriously, what is the pattern?
Seriously do you read. I wrote in the first sentence:
>> If there was a CQRS principle it would be something like this:
I was not stating that what CQRS is, I'm trying to give an example of what CQRS would be if it was Software Design Principle.
Patterns also follow design principles. Yet a Principle is not a result of a composition of Principles, in other words its not decomposable. Having model for query and a model for commands is not a fundamental law of software design, as such its not a Principle.
You may be wandering, what about SOLID? Well, SOLID its not a Principle either, its a Doctrine. A set of principles to be followed in software design. CQRS is not such thing either.
Each teams chooses the design principles over which his domain model will be designed. That makes the teams doctrine, it can be SOLID or something else-
Yet CQRS is more of the kind: "reusable software solution for a recurrent problem". First you need to identify the problem then look for the solution. CQRS can be it or not.
IMHO the kind of position you adopt towards CQRS, is IMHO the source of many problems.
Precisely because people think that its a Design Principle they stop looking at problem(s) for which CQRS was designed to deal with. Hence people apply it thinking that by following the rules described in the CQRS Pattern they will end up with a better design ... and the result is catastrophic! Why? Because the problems addressed by CQRS weren't there in the first place!
Now a Design Principle is not really such a case, if you don't follow the principles even though ones design may end up being bad, most probably you would get a far worst design if you did not followed them.
Cheers,
Nuno
I understand that... my point is, if its a pattern, describe it? How
is separating commands and queries a pattern? Furthermore, I directly
relate CQRS to the business domain. As a BDD(context specification)
practicioneer, I find it to be a natural way to interact with the
business domain expert. It helps frame the domain discussion around
behavior(commands) and the outputs(queries producing views). This is
not a pattern.
>
> Having model for query and a model for commands is not a fundamental law of software design, as such its not a Principle.
>
True is NOT a fundamental law of software design, however, it MOST
certainly is a fundamental law for CQRS. If you do NOT separate
commands and queries have you applied CQRS? Again, how is separating
read from write operations a pattern?
> You may be wandering, what about SOLID? Well, SOLID its not a Principle either, its a Doctrine. A set of principles to be followed in software design. CQRS is not such thing either.
Each letter in SOLID is a principle. I was drawing a comparison to
CQRS as a single principle say... SRP. That said, SRP is also a root
principle of CQRS.
> Precisely because people think that its a Design Principle they stop looking at problem(s) for which CQRS was designed to deal with. Hence people apply it thinking that by following the rules described in the CQRS Pattern they will end up with a better design ... and the result is catastrophic! Why? Because the problems addressed by CQRS weren't there in the first place!
I agree with the later part. However, teams can inappropriately apply
either a principle or pattern. Thats a discipline issue... or perhaps
even a business constraint.
True is NOT a fundamental law of software design, however, it MOST
certainly is a fundamental law for CQRS.
True is NOT a fundamental law of software design, however, it MOST
certainly is a fundamental law for CQRS.
As a BDD(context specification)
practicioneer, I find it to be a natural way to interact with the
business domain expert. It helps frame the domain discussion around
behavior(commands) and the outputs(queries producing views). This is
not a pattern.
This assumes a CQRS pattern can tell me how to separate the commands/
queries in any business domain... digital pathology, glass bottling,
etc. A software pattern cant prescribe a way to do that. It requires
business domain experts and CQRS mindset to frame the discussions of
how customers already want to talk about their domains... ie... the
commands(behavior) and its outputs(queries). That is the most elegant
part of CQRS mindset. Elegant because its crazy simple.
This statement also assumes this is an actual software pattern that is
uniquely "CQRS". In code, i would use resolve command messages to
command handlers... the command pattern. Thats not called the CQRS
pattern. Its the command pattern.
CQRS as a principle can be a business domain exercise. Not a coding
exercise.
> > As a BDD(context specification)
> > practicioneer, I find it to be a natural way to interact with the
> > business domain expert. It helps frame the domain discussion around
> > behavior(commands) and the outputs(queries producing views). This is
> > not a pattern.
>
> I think it is better for you to you provide an example of this. Through it your point might cross much better.
Probably should create a separte discussion thread for that.
> I feel that your are making CQRS much more then actually is. A very simple Pattern.
Quite the contrary. The point of these 70+ threads is that is crazy
simple. The complexity can be incrementally added in as the result of
being disciplined around thinking about the business domain as
commands and queries. By complexity, I mean infrastructure to
implement EDA using a service bus with message queues etc.
In fact its so crazy simple... you dont need a framework. :)...
although you might use one for ES, service bus, etc.
Honestly I don't understand. You say that simply separating a set of commands from the queries helps you driving BDD and communication with the stake holders and conclude as such is a Principle.
I'm asking for example to understand your stake. I gave examples to sustain mine, I think it is the least you could do to sustain yours.
Sent from my iPhone
So... a contrived business domain example ...using the digital
pathology field as an example... I might have a stakeholder story like
this:
[Epic - story is nothing more than a placeholder for a conversation]
In order to review a patient case outside the hospital
as a pathologist
I want to be able to view a scanned image of a slide over the internet
This story might drive a conversation to the following context
specifications (which incidentally is the acceptance criteria):
When opening a case
- It should display the case number
- It should display the list of associated scanned images
At this point of the discussion, I would interpret the stakeholders
description as a view which will result in generating a query object
(perhaps with a case id) and a query handler that can retrieve
(obviously ignoring the details about transport over HTTP.. maybe its
a web service from the client maybe its just a page request). In
either case, I have a query
When the slide (scanned image) has been viewed
- It should mark the slide as viewed
I would interpret this to be a command(behavior). I'd create a command
object and command handler. "IF" your applying DDD, I'd retrieve the
Case AR and execute the MarkSlideAsViewed(slideId). Perhaps your using
ES ... perhaps not. Obviously, this would be in a transaction etc etc.
Point of this is .... CQRS is first and foremost about the business
domain. Communicating with the customer to drive out commands and
queries. But they are none the wiser because I never forced them to
talk about command & queries rather i talked about their domain.
The benefit of CQRS thinking is I now have separated those
responsibilities and I easily begin scaling the system... as the
requirements and project progress dictates. I dont need to concern
myself with other architectural details until the last responsible
moment. The fact that I separated them at the onset, I can easily
address the complexities as the life of the project continues.
On Nov 18, 1:50 pm, Nuno Lopes <nbplo...@gmail.com> wrote:
> Why not this thread?
>
> Honestly I don't understand. You say that simply separating a set of commands from the queries helps you driving BDD and communication with the stake holders and conclude as such is a Principle.
>
> I'm asking for example to understand your stake. I gave examples to sustain mine, I think it is the least you could do to sustain yours.
>
> Sent from my iPhone
>
> > although you might use one for ES, service bus, etc.- Hide quoted text -
I would immediately create those specifications in code as
unimplemented spec... probably using a tool like MSpec. Incrementally,
I would begin building the command object and command handler; the
query object and query handler. Heck, I dont even need an actual data
store yet. I would drive out the use cases through working software
and deliver continuously placing working software in their hands.
Because of CQRS as a principle, I drive out commands and queries. When
and IF my project continues to grow... the other stuff will come in
due time. However, I could NOT easily take advantage of partionability
unless I first separated those things into separate objects.
At this point, I only need to use the command pattern. I only need a
simple dispatcher(invoker) that uses my container to match a command
object to a command handler and execute the handler. Much of the other
stuff is architectural.
At the domain model (persistent model) level, yes, I would absolutely
use ES. ES is super easy... even without a framework, although I'd be
incline to use Jonathon Olivers event store. My AR would only have
methods.
...
> > - Show quoted text -- Hide quoted text -
Thank for explaining the CQRS principle. Now it's crystal.
So you discovered Structured Programing and Structured Design with CQRS, that is a good thing.
Cheers,
Nuno
As new-comers want to learn about CQRS, emphasising CQRS as a
principle would deliver the essence quicker... IMHO of course. No
special patterns are required. Do you know the command pattern? Then
you already know how to get started coding. No framework is needed to
get started. As they grasp those concepts, CQRS as an architecture
"CAN" evolve to include the other orthogonal stuff. The other
orthogonal stuff has already been well defined and patterned... and
includes frameworks for those things.
I guess that Udi and Greg meet so many people in that poor situation that they feel the need to make a detour into those aspects of software design before actually diving into the relevance of having two models and why it solves some problems.
Building a facade of procs around our domain models is a quite common to.
I ask the community this.
If you feel that you don't need two models (I means models has a collection of data structures and algorithms), one for focused on providing services to query information and another for processing information, why would you need CQRS? I think most people don't know the answer to this question, hence are looking for a solution to a problem they never met and don't have.
On the other side, if you ever needed to deal with the impedance mismatch between supporting and using structures and algorithms for reading and for processing that CQRS might be for you.
I think this is crucial to understand CQRS.
Cheers,
Nuno
PS: An example of a structured programming language is C.
I am not trying to prove "scritchy", NCQRS, Lokad.CQRS, Axon or any
other framework to be wrong. Specific categories of developers love to
FIRST jump to the code and frameworks. As a result, they miss the
essence and dont understand the "why". I'm emphasizing when/where and
what type of framework is needed when applying CQRS. Specifically, a
framework is NOT needed to get started. At the coding level, the
command pattern is all you need.
On Nov 19, 7:51 pm, Tom Janssens <d4sk...@gmail.com> wrote:
> I got tired of all this theoretical mumbo-jumbo, so I implemented what I
> consider a minimal CQRS app, in order to prove you can do both CQRS with
> and without a framework:
>
> Architecture & all the blah in a single c# file:https://github.com/ToJans/MinimalisticCQRS/blob/master/MinimalisticCQ...
>
> UI in a single htm file (warning: ugliest layout in the world IMO - true
> developer art):
>
> https://github.com/ToJans/MinimalisticCQRS/blob/master/MinimalisticCQ...
>
> Demo over athttp://minimalisticcqrs.apphb.com/
+1
For me, I also believe CQRS (as a princple) is valuable in situations
where impedance mistmatch is NOT a concern. Because no special
framework or coding practice is required to get started, teams can
deliver working software quicker. However, "IF" the project begins to
grow, the separation of commands/queries will provide a strong
foundation to address things like impedance mismatch.
This why I believe CQRS is a principle. Teaching CQRS as a principle
will help people address those problems when/if they encounter them.
In the meantime, the reap the benefits of SRP and simple, supple
design that is NOT burdened by learning a framework. Of course, I am
assuming most teams already know the command pattern or could at least
learn it in 5 minutes.
As a basketball coach, young players often express their displeasure
for performing drills. Its not until we run the offense in a game
situation that they realize those drills help them execute the
offensive play. I think this basic idea exists with CQRS.
For me, I also believe CQRS (as a princple) is valuable in situations
where impedance mistmatch is NOT a concern.
For me, I also believe CQRS (as a princple) is valuable in situations
where impedance mistmatch is NOT a concern.
--
Le doute n'est pas une condition agréable, mais la certitude est absurde.
True. You are correct that at enough higher level all that matters are commands and queries. This is just not a perk of CQRS. But at that level there is really little one can do if there is a design flaw in the system without major $$$.
Cheers,
Nuno
I've not been following your developments as I would like. Having said this it seams that most the concerns addressed in your blog are around Aggregates, Event Sourcing, Bounded Contexts and other DDD Patterns, and how you applied CQRS on top of those.
These Patterns are for me orthogonal to the CQRS Pattern and with each other (yes, I can use Bounded Context without CQRS or even Aggregates). In ones design we can get them together of course.
From this I believe that you have far more DDD stuff in your bag then CQRS that empowers your remark.
Greg's experience in Financing and EDA opened my eyes not with CQRS, but a very simple thing. Command -> Aggregate -> Event/Fact ... this for me is really powerful, way beyond CQRS. You seam to use this heavily.
Cheers,
Nuno
PS: Maybe its me, but when people start taking about Maturity Models, Meta Models etc, around a Pattern as simple as this I get the shivers. Maybe we should talk about MVC, Specification, Command Pattern, CQRS, Table Module, Presentation Model, Domain Model .... Maturity Models, Meta Model and so on.