It would seem to be the case, CQRS and repository are not mutually exclusive patterns, far from it actually. They are quite often used together. I would say CQRS is far broader pattern than the repository which is simply to abstract the data store mechanism whereas CQRS is a functionally more complex pattern. I would be curious how they are storing commands and interacting with the query engine though.
- Glav From: [email protected] [mailto:[email protected]] On Behalf Of Nathan Schultz Sent: Thursday, 14 July 2016 5:13 PM To: ozDotNet <[email protected]> Subject: Re: Command and Query Responsibility Segregation Pattern (CQRS) Hi Tony, Yeah, it seems strange to me too. Often CQRS is sometimes used in conjunction with Event Sourcing (i.e. an append only data-store). So maybe he's thinking of the Repository Pattern as a traditional CRUD interface, and it's that which they're not using? Regards, Nathan. On 14 July 2016 at 14:03, Tom Rutter <[email protected] <mailto:[email protected]> > wrote: Hey Tony, I too am confused by the developer's comment. My understanding is the same as yours it seems. On Wed, Jul 13, 2016 at 8:12 PM, Tony Wright <[email protected] <mailto:[email protected]> > wrote: Hi all, I had a discussion the other day with an experienced developer who told me that "instead of using the repository pattern, they just use CQRS these days." I am somewhat puzzled with that statement, because it is my understanding that the two are almost completely independent of each other. In simple terms, CQRS is used to separate requests from responses, so data received from a database use different classes from the ones used to submit updates. e.g. PersonCreateInputDto, which might contain just the fields used to create a new person in the database, and PersonOutputDto, which might contain just the fields needed to display a list of Person records. You don't use the same object for both types of transaction, just the bare minimum in each. Repository, on the other hand, is used for dependency injection. By changing the dependency provider, I can switch a set of runtime classes with a set of testing classes. The dependency provider injects the dependent objects that are desired at the time, which could be either runtime objects, or mock testing objects, so it is predominantly used to enable better testing. I got the impression that the person was somehow using CQSR to perform their testing instead. Is there something that I'm missing here? Regards, Tony
