Support Center & Knowledge base

Patterns

Backend

Command Query Responsibility Segregation

Most systems has different requirements for the read and the write part of each bounded context. The requirements vary on what is needed to be written in relation to what is being read and used. The performance characteristics are also for the most part different. Most line-of-business applications tend to read a lot more than they write. CQRS talks about totally segregating the read from the write and treat them uniquely. One finds event sourcing often associated with CQRS, something that Dolittle has embraced and helps bridge the two sides and stay completely decoupled. It is an optional part of Dolittle but hightly recommended together with an event store.

Simple CQRS Diagram

Frontend

Model View View Model

MVVM is a variation of Martin Fowler’s Presentation Model. Its the most commonly used pattern in XAML based platforms such as WPF, Silverlight, UWP, Xamarin and more.

Model

The model refers to state being used typically originating from a server component such as a database. It is often referred to as the domain model. In the context of Dolittle, this would typically be the ReadModel.

View

The view represents the structure and layout on the screen. It observes the ViewModel.

ViewModel

The ViewModel holds the state; the model and also exposes behaviors that the view can utilize. In XAML the behaviors is represented by a command, something that wraps the behavior and provides a point for execution but also the ability to check wether or not it can execute. This proves very handy when you want to validate things and not be able to execute unless one is valid or is authorized. Dolittle has the concept of commands, these are slightly different however. In fact, commands in Dolittle is a part of the domain. It is the thing that describes the users intent. You can read more about them here. In the Dolittle JavaScript frontend however, the type of properties found with the XAML platforms can also be found here. Read more about the frontend commands here.

Binding

Part of connecting the View with the ViewModel and enabling it to observe it is the concept of binding. Binding sits between the View and the ViewModel and can with some implementations even understand when values change and automatically react to the change. In XAML, this is accomplished through implementing interfaces like INotifyPropertyChanged and INotifyCollectionChanged for collections.

Dolittle have full client support for both XAML based clients and also for JavaScript / Web based. For XAML and what is supported, read more in detail here. For the JavaScript support, Dolittle has been built on top of Knockout that provides obervable() and observableArray(). Read more about the JavaScript support here.

Figures

A traditional MVVM would look something like this:

MVVM Architectural Diagram

With the artifacts found in Dolittle and more separation in place with CQRS, the diagram looks slightly different

MVVM Architectural Diagram - Dolittle artifacts

You can read more details about the MVVM pattern here.