Using domain events to express some reached state

In general, domain events are used to make a notification, when something has happened to entity, but is it okay – from perspective of ddd – to use domain events to make a notification, when entity reach a some specific state? For example “PersonIsValidToDoSomethingEvent” or “PersonHasReachedSomeStateEvent”?

Matthias Verraes describes domain events as follows (highlight added):

Domain Events are a special type of Event messages. A Domain Event is
something that has happened in the past, that is of interest to the
business.
This last distinction means we separate all technical
concerns from the domain. Usually, the distinction is very clear. In
other cases, we should validate with the business whether they are in
fact interested that this Domain Event has happened. In rare cases,
the line between technical and domain events is blurred

“PersonIsValidToDoSomethingEvent” sounds like it would be of interest to the business and not just a technical concern.

But don’t confuse domain events with event sourcing. With event sourcing, the event stream becomes the single source of truth and define the current state. These persisted events are restricted to “when something has happened to an entity”.

Domain events may or may not be used for event sourcing.

1

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *