Book Image

SignalR Blueprints

By : Einar Ingerbrigsten
Book Image

SignalR Blueprints

By: Einar Ingerbrigsten

Overview of this book

Table of Contents (18 chapters)
SignalR Blueprints
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
9
Debugging or Troubleshooting
Index

Command Query Responsibility Segregation


To be very clear, the ideas of CQRS have no relation with DDD but are often related to each other with the behavior of the domain being represented by commands. CQRS is decoupling on an architectural level. DDD is complementary in CQRS, and with Bifrost, the building blocks of both go together. CQRS was coined by Greg Young and Udi Dahan a few years ago and was loosely based on Command Query Separation (CQS) defined by Bertrand Meyer in 1988. It states that every method should either be a command that performs an action, or a query that returns data to the caller. A method should never do both these things; if put in another way, asking a question should never change the answer.

Let's take a look at the following pseudo sample:

public class CustomerService
{
   // Commands
   void MakeCustomerPreferred(CustomerId)
   void ChangeCustomerLocale(CustomerId, NewLocale)
   void CreateCustomer(Customer)
   void EditCustomerDetails(CustomerDefails)

   //...