Terminology / how the framework works

CQRS: the domain model is write-only. There is a seperate ViewModel for querying. The models are kept in sync by messages from the domain model to the ViewModel.
Event Sourcing: state in the domain model is persisted by storing all state change events. To get the current state of an object, you have to replay the events that occurred during the lifecycle of that object.
These patterns are based on the foundation of DDD, which has it's own jargon. It's recommended to read the book by Eric Evans on the topic.

The concepts mentioned above are formalized in the Agr.CQRS framework. It has made the framework quite intrusive, but I don't see another way.

Entities and Aggregates:
  • Domain entities derive from Entity
  • The Entities belong to an Aggregate
  • The AggregateRoot derives from AggregateRoot.

Commands and Events to change state:
  • Command derive from Command and are Issued through a CommandIssuer
  • Commands are routed by the CommandRouter to a CommandHandler that is designed to handle that specific command
  • CommandHandlers can use the DomainRepository to obtain an AggregateRoot in its current state.
  • The CommandHandler calls domain (UL named) methods on the AggregateRoot or Entities, parameters are used from the Command.
  • The Entities don't change state, but do validation and fire DomainEvents with the requested state change.
  • Internal event handlers in the Entities change the state
  • When a Command is finished, the resulting DomainEvents are captured and persisted, so they can be replayed to restore the object later.
  • The DomainEvents are propagated to the external world

Querying
  • ViewModelUpdaters listen to this propagation (actually, in the framework they poll the datastore for changes)
  • ViewModelUpdaters update there ViewModels where needed.
  • a ViewModel is a naive accumulation of data that is needed in one situation (on one screen for example).

This is hard to grasp. I hope the Examples make it clearer

Last edited Mar 5, 2010 at 8:57 PM by jwboer, version 2

Comments

No comments yet.