Principles
This document describes almin's principles:
CQRS
Command and Query Responsibility Segregation(CQRS) is a pattern.
"CQRS is simply the creation of two objects where there was previously only one. The separation occurs based upon whether the methods are a command or a query (the same definition that is used by Meyer in Command and Query Separation: a command is any method that mutates state and a query is any method that returns a value)." -- CQRS, Task Based UIs, Event Sourcing agh! | Greg Young
CQRS separates "one" model to "two" models. CQRS has two models that are Command(Write) model and Query(Read) model.
For example, Flux's store is a "one" model, but it is also Write and Read model.
In Flux
Flux architecture defines Stores role.
Stores contain the application state and logic. -- Stores
It means that Store is a single model, but has two task - state
and logic
.
- On Application Layer: Store has application state
- On Domain Layer: Store has business logic
Complexity
The Complexity: N × M (multiplication)
Store is both Write stack and Read stack.
- N: Store does logic and updates State(Write)
- M: Store returns State for View(Read)
In Almin/CQRS
Almin separates Store's two task to one task.
Store has only state
role and Almin moves logic
to domain model.
(Domain model has business logic)
Additionally, Almin introduces domain model for logic
role.
- On Application Layer: Store has application state
- On Domain Layer: Domain model has business logic
Complexity
The Complexity: N + M (addition)
Domain model is write stack and Store is read stack.
- N: Domain model does logic and updates State(Write)
- M: Store returns State for View(Read)
Almin aims to reduce the complexity at large application.
Quote from Microsoft .NET - Architecting Applications for the Enterprise (2nd Edition) (日本語)
Related:
Unit of work
Almin has a Unit of Work. It is a actual internal class and Almin applies Unit of Work pattern.
- Unit of Work can stop unintended updating of
StoreGroup
- In other word, The user can control updating of
StoreGroup
while a series of UseCase is executing
The following figure describes it: