Articles

About Commands

Commands A Command is a typed representation of the user’s intent in performing an action. As such, it is a simple Data Transfer Object and performs no logic or calculations. It is an instruction to the system to do something. This is a central part of the CQRS pattern, which separates the Command and Query parts of a system. A user does not have to be a person. Another system can issue commands to our system and will the be considered a user. »

About Concepts and Value Objects

Background Objects which have identity, fall into two distinct categories. Entities and Value Objects Entities Entities have a unique key, usually a single value but in some cases a composite of multiple values, that identifies the instance of the entity. When comparing two instances it is sufficient to compare the identities of those entities. An entity will have the same identifier throughout the lifetime of the system, even though it may be represented by different classes and objects hroughout its lifetime. »

Aggregates and Aggregate Roots

Background An Aggregate is an object or collection of objects (Entities and Value Objects) that must be treated as a single unit for the purposes of a business transaction. The Aggregate will maintain all invariants for all objects that comprise the Aggregate, enforcing all business rules internal to the Aggregate. Aggregate Root All Aggregates have a single point of entry that is know as the root. The Aggregate Root is the interface to the external world. »

Artifacts

Artifacts Definition An Artifact is a representation in our domain that we wish to evolve through time independently of any particular code type that it may have been expressed in. Introduction An Event Sourced system makes migrations and versioning explicit, rather than implicit or one-off data migrations. However, in terms of code representations (classes, structs, interfaces, etc.), the read-only, append-only nature of persistence coupled with the need for a long-lived evolving system, can present challenges. »

Bounded Context

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. DDD Bounded Context Definition A bounded context defines the boundaries within which a Domain Model and Ubiquitous Language are valid Intro In a large system, you find that the system is not a single monolithic system, but rather a composition of smaller systems. »

Convention over Configuration

For a team to deliver consistency in the codebase, one should aim for a recipe that makes it easy to the right thing and hard to the wrong thing. Most software projects tend to put in place both formal rules and informal rules in the codebase that are recipes considered good for the project. These are often aimed at increasing the productivity of the developer and making it more predictable where and how to do things. »

Domain Events

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. Definition A Domain Event is a serializable representation of a fact that has happened within your domain. The definition of a Domain Event is simple, however it has some profound implications for systems that utilise Domain Events. “a fact” A Domain Event is a change (fact) within our Domain. »

Event Sourcing

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. Definition Event Sourcing is an approach that derives the current state of an application from the sequential, incemental changes (events) that have happened within the application. Managing State While Event Sourcing is a fringe approach for maintaining state within application development, it has a long history within mature business domains, especially where there is a requirement to have a dependable audit log (e. »

Event Store

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. Event Store An Event Store is the mechanism by which a stream of events are persisted to durable storage. It is the storage mechanism for an Event Sourced system (see Event Sourcing). Basics There are two fundamental concepts for the Event Store: »

Handling Commands

Command Handler Background A Command Handler handles commands. The command handler is responsible for executing the appropriate methods on Aggregate Roots and Domain Services to fulfill the intent of the Command. Requirements A Command Handler must implement the IHandleCommands interface. This is a simple marker interface with no methods to implement. To handle a Command, you create a method called Handle with a single parameter that is the Command you wish to handle. »