Command-Query responsability segregation and change notification
Hi
I am build a large application and have based it around the Comand-Query responsability segregation pattern for a number of reasons (allowing me to segregate the work between developers with lower model-contention and also because the command side triggers some complex actions) but am wondering on the best approach to data-impacting commands.
Currently thinking that the command library should expose a pub-sub notification library that a UI can hook into and listen for messages that tell it "a data impacting thing has occured - you shoud refresh your data". However this violates the "make your UI as dumb as possible" rule.
Any other ideas on how I should do this?
Re: Command-Query responsability segregation and change notification
To add a bit of colour - this is a financial applicatio and the "commands" would do things like placing trades on the market as well as saving data so that makes the segregation of "read data" and "do something" more sensible.
But the command might need the source data updating i.e. "I know you wanted to execute this at a price of $20.34 but the price has moved on to $20.55 and because that price is within limits I executed it anyway - you need to update your calcs..."
Re: Command-Query responsability segregation and change notification
How are you communicating between the UI and the backend that knows that "data impacting has occured"??
Are they on different machines - workstation and server, for instance??
Re: Command-Query responsability segregation and change notification
Yes - different machines. The UI is (probably) going to be silverlight communicating over WCF.
I think the UI is going to have to sub to an event e.g. "I am currenty looking at this x" and then a message is posted to tell it "you know you are looking at x? well refresh your cache because it has changed"..
Re: Command-Query responsability segregation and change notification
Should anyone be thinking about this, my experience is that the CQRS architecture works very well for a big team that needs to move fast as it prevents "model contention" but you do need to spend a lot of time explaining what you are doing to developers who are used to "understanding the logic by looking at the database".