Skip to content
forked from tpierrain/CQRS

A simple project to explain CQRS during a live coding session at MS experiences'16

Notifications You must be signed in to change notification settings

vnextcoder/CQRS

 
 

Repository files navigation

BookARoom

BookARoom is a simple project to explain CQRS during a live coding session at MS experiences'16 (slides are available here: https://github.com/tpierrain/CQRS-slides) or here on slideshare

The project is a dotnet core ASP.NET web site (in order to be containerized in the next session), allowing users:

  1. To consult and search for available rooms (READ model)
  2. To book a room (WRITE model)

Of course, booking a room (write model) will impact the read model accordingly.


disclaimer

This project is not a real one nor a prod-ready code. The intent here is to illustrate the CQRS pattern during a 40 minutes session. Thus, some trade-offs have been taken in that direction (e.g. the usage of Command and Queries terminology instead of domain specific names that I would have used otherwise).

CQRS without Event Sourcing?!?

Yes, since the timing will be short for this MS experiences'16 session in Paris (no more than 30 minutes of live-coding), I've decided to focus only on CQRS pattern, WITHOUT Event Sourcing (ES). Indeed, ES is often a mental dam for people's understanding. I also find important that people understand that CQRS loves Event sourcing, but CQRS != Event sourcing.


Highlights of the talk

  1. CQRS (WITHOUT Event Sourcing):

    • Why CQRS?
    • Pattern origin
    • How read and write models articulate
    • Eventual consistency challenges and options
    • Short clarification between CQRS & Event sourcing
  2. How Outside-in TDD works

  3. How Hexagonal Architecture can help us to focus on Domain first, before tackling the infra code (ASP.NET) in a second time

  4. What is dotnet core and how it articulates with the new version of ASP.NET


Projects & Dependencies

  • directory BookARoom.Domain: containing all the domain logic of the solution (for both read and write models). (has no dependency)

  • directory BookARoom.Infra: containing the reusable infrastructure code (i.e. non-domain one like adapters, command handler, repositories) for both read and write models. (depends on both Domain and IntegrationModel projects)

  • directory BookARoom.Infra.Web: ASP.NET core project hosting the web infrastructure code (like ViewModels, Views and Controllers) which relies on the BookARoom.Infra code. (depends on both Domain, Infra and IntegrationModel projects)

  • directory BookARoom.Tests: containing tests for all projects. (depends on all the other BookARoom projects)

  • directory BookARoom.IntegrationModel: command-line project to generate integration json files for hotel (from code). (has no dependency)


Tips and tricks

How to run the tests

Note: resharper and ncrunch don't support yet dotnet core; you can only run them via Visual Studio test runner (e.g. Ctrl-R, A) or by executing:

 dotnet test 

within the BookARoom.Tests project directory.


CQRS in a nutshell

There are many forms of CQRS implementation. The implementation of the BookARoom project follows this version:

directory

from original source: https://msdn.microsoft.com/en-us/library/jj591573.aspx


lab

The objective of this lab is to add the "cancel a reservation" feature.

Step by step Instructions (following outside-in TDD technique) are presented here.


Tracks of improvement

  1. Fight against the current anemic model (mainly because I never worked on that topic and that I don't have any expert available to help me ;-( and embrace more the ubiquitous language of this domain.

...

About

A simple project to explain CQRS during a live coding session at MS experiences'16

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.4%
  • CSS 1.7%
  • Other 0.9%