Does any one know where to find example code for an implementation of Domain Events as described by Udi Dahan in Domain Events – Salvation?
A domain event is, something that happened in the domain that you want other parts of the same domain (in-process) to be aware of. The notified parts usually react somehow to the events. An important benefit of domain events is that side effects can be expressed explicitly.
A Domain Event is an event that is spawned from this model that is a result of a decision within the domain. Within the model our Aggregates have the role of maintaining business rules and this is where we implement decision points in our model, so the Aggregates are also responsible for creating the Domain Events.
An aggregate is a domain-driven design pattern. It's a cluster of domain objects (e.g. entity, value object), treated as one single unit. A car is a good example. It consists of wheels, lights and an engine.
A better implementation of Domain Events, in my opinion, can be found at https://github.com/bsommardahl/BlingBag. There's a sample application and implementation instructions. I like this implementation more because it doesn't use the static class to raise domain events and doesn't couple your domain to your infrastructure. Instead it uses plain ole c# events and initializes them in the services that return your domain entities (like your repository or a fetcher service).
DDDSample.Net has one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With