Skip to content

Use cases, event handlers and scheduled jobs

What the system does: use cases (commands and queries) called by roles, event handlers triggered by events, scheduled jobs on a schedule.

Use cases

A use case is one command or query of the system, such as Place order, Reserve stock or Get order status. It belongs to one bounded context or to the project, and has:

PartWhat it holds
KindCommand or Query.
RolesThe roles that call it.
InputsEach with a type.
StepsPlain sentences, indented for sub-steps.
OutcomesEach with a name, whether it succeeds, a code and a message, and what it returns.

Event handlers

An event handler reacts to an event: a domain event of an aggregate or an integration event. It has a description and steps. Use one for "when a payment is captured, confirm the order".

Scheduled jobs

A scheduled job runs on a schedule written in plain language, such as "every night at 02:00 UTC", and has steps: release expired reservations, send reminders.

Where behaviour sits

The Behaviour group of the sidebar lists every use case, handler and job of the project; a bounded context's Behaviour tab lists those that belong to it.

Tip

Keep behaviour in the context that owns the data it changes.

Next steps