I'm thinking about applying CQS for my ASP.NET MVC web site, but in a very simple matter. I don't mean CQRS, because I want to use the same data source for query and command parts, and so I don't need event sourcing and other more complex patterns.
So, what I have in mind is:
The main thing I want to achieve is:
Does this make sense?
CQRS takes the defining principle of CQS and extends it to specific objects within a system, one retrieving data and one modifying data. CQRS is the broader architectural pattern, and CQS is the general principle of behaviour.
Command-query separation (CQS) is a principle of imperative computer programming. It was devised by Bertrand Meyer as part of his pioneering work on the Eiffel programming language. It states that every method should either be a command that performs an action, or a query that returns data to the caller, but not both.
CQS (command–query separation) - is a principle that defines data model of a system in terms of queries and commands: Commands affecting state of object and provide a simple way to execute a single operation in terms of domain model. Queries allows to query information from a data source without affecting it's state.
CQRS stands for Command and Query Responsibility Segregation, a pattern that separates read and update operations for a data store.
So, to answer your question, yes I think it makes sense.
I'm not sure what else you're looking for. I think the approach you're taking makes sense and should give you what you are looking to do.
In my opinion, CQS and CQRS are very similar, where CQRS has the concept of separate read and write stores (and some would argue that the write store may not even be necessary). Event sourcing isn't really part of CQRS - it's an add-on, so to speak, that fits in nicely with the distributed nature of CQRS.
What you're giving up with your approach is some of the scalability of the data since you're flattening the data using views. But if your app doesn't require it, then there's no problem there.
Also, it may be useful to read Udi Dahan's article on when to avoid CQRS. It probably helps justify your decisions. It caused quite a stir when he released it. But between him and Greg Young, they're the experts on CQRS.
I'm not sure if I answered your question or helped, but good luck with your project! I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With