Question

The project, I am currently working for and based on a Java-Web stack (Spring, Hibernate, HTML5..), is using the approach of Domain-Driven-Design principles for design and development.

Our team is asked to implement an accounting system that will respond to business events (like requesting a payment to a customer or receiving the payment) by creating and storing accounting entries. It seems that the accounting patterns of Martin Fowler advocates the usage of an event-based system. So my question is the following :

  • Are domain events the right approach to use for this purpose ?
  • If yes, what are the benefits compared to the time to implement a new Event mechanism in our project ?

Thank you very much for your help.

Was it helpful?

Solution

Accounting is typically a downstream bounded context in DDD parlance. This means that accounting actions are created in response to events from other systems. As you point out, Martin Fowler's accounting patterns reflect this as well.

Whether a domain event infrastructure as described by Udi is the right approach depends on what your current system looks like. What Udi describes is a framework for publishing domain events directly from domain entities. If this is the preferred approach for you then go for it. What you should take into account is 1) the described framework isn't trivial - you have to take care of threading issues as well as transactions, 2) it addresses publishing events within a single process and you if you need to publish to other systems you will need to implement a dispatcher.

The important takeaway is the concept of the domain event itself - an indication of something "interesting" happening in the domain. An event-driven modelling methodology is a shift in paradigm from other approaches. How they are published is of lesser importance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top