First approach with CQRS

I’ve started to use CQRS at work last week.

On my project, this used to be the architecture layering: an MVC app, with some logic on the Controllers that call n services that get the data from the repositories, bring the model back to the controller and render the page. Job done.

Number of classes needed to get some data from the DB to the UI:

1 controller + 1 test class

1 query class

1 service + 1 test class

1 repository + 1 test class

1 response data model

 

8 files

image2

We’ve recently started to investigate CQRS, and we are now having 2 different scenarios: query and command.

The most complex scenario is when The UI call a controller action to do something and get some data back. in this case I need to create:

1 controller + 1 test class

1 query object

1 service to wrap the business logic + 1 test class

1 command handler + 1 test class

1 command

1 repository to read from the db + 1 test class

1 repository to write to the db + 1 test class

1 response data model

13 classes

image1

 

Basically to solve the most common problem (execute a command and get some data back to the UI) I now need 13 classes rather than the usual 8 I was using before.

It looks like a lot more work to do, let’s hope the Responsibility Segregation and the ease of testing each different class and piece of code will be good in the long term.

 

I got a code example for CQRS from Mark Nijhof:
MarkNijhof/Fohjin – GitHub http://bit.ly/v2c9Ts

Few more articles I recommend to read:

Martin Fowler: CQRS http://bit.ly/sFPqcR
CQRS, Task Based UIs, Event Sourcing agh! | Greg Young http://bit.ly/uUkgr7
Elegant
Code » CQRS à la Greg Young http://bit.ly/uZUhsE

SkyDrive vs Office 365 vs Evernote (my 2 cents)

So, what is SkyDrive and what is Office 365? There seems to be a lot of confusion on the web about what one is and what the other one is. I think the confusion comes from the fact that Microsoft is trying to market Office 365 as the “Online collaboration tool”, implicitly saying that you cannot collaborate using SkyDrive that is marketed as “Online document storage and file sharing“.

Do you need Office 365 to collaborate?

No, you do not.
Well, if for collaborating you mean sharing a calendar, appointments, emails (Exchange), managing a complex documentation system for your company (SharePoint), connect with others using IM and do video sharing, online conference calls, etc… (Lync) then Office 365 is what you need.

Of course, if you are a non professional user (or a self managed professional) you probably do not need all the features offered by Office 365, but you might occasionally need to share and collaborate with other people on some office documents.

What you really need is SkyDrive.

Do you need Evernote to collborate?

No, you do not.

Evernote is a wonderful cross platform to create and share notes, but you can share only notes, there’s not a concept of folder, and there’s not a concept of Spread sheet (you do not always share just text)

What you really need is SkyDrive and OneNote

Let me show you what you can do with SkyDrive:

First of all, open Skydrive and login with your Windows Live account.

Create an Online Word document in SkyDrive

  1. Click on the work icon next to Create on the SkyDrive toolbarimage
  2. Name your document
    image
  3. Use Word Web App to edit the document
    image

Open an existing Online Word document using Word 2010

  1. Just click on the Open in Word button on the toolbar
    image
  2. Confirm that you want to open the document
    image
  3. Click on Enable Editing
    image
  4. Change the document and hit the sync button
    image
  5. At this point if you reopen the document from the browser in SkyDrive using Word Web App you’ll see the change that was made

Share an existing Online Word document via SkyDrive

  1. Open the document in SkyDrive
    image
  2. Add a list of emails you want to share the document with
    image
  3. Send a message to the people you want to share the document with
    image
  4. They’ll receive an email with a link the the online Word document they can start to edit

Share a SkyDrive folder with other people

  1. Open SkyDrive
  2. Select a folder
    image
  3. Edit Permissions
    image
  4. Select the people you want to share the folder with
    image
  5. they’ll receive an email with the link to the SkyDrive folder you’ve shared with them and will be able to work with you on documents you’ve shred with them. You can edit the same document at the same time and every change will be synchronized in real-time with  all the people editing the document at the same time