Saturday, July 18, 2015

CQRS vs CRUD

CQRS
Martin Fowler
"CQRS stands for Command Query Responsibility Segregation. It's a pattern that I first heard described by Greg Young. At its heart is the notion that you can use a different model to update information than the model you use to read information. For some situations, this separation can be valuable, but beware that for most systems CQRS adds risky complexity

The mainstream approach people use for interacting with an information system is to treat it as a CRUD datastore. By this I mean that we have mental model of some record structure where we can create new records,read records, update existing records, and delete records when we're done with them. In the simplest case, our interactions are all about storing and retrieving these records."

CRUD:

CQRS:



CQRS Journey @ Microsoft Patterns & Practices

"Command–query separation (CQS) is a principle of imperative computer programming...
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. In other words, Asking a question should not change the answer.[1] More formally, methods should return a value only if they are referentially transparent and hence possess no side effects."