Question

I just read Vernon's book "Implementing Domain-Driven Design". What I couldn't find is where to put your Domain Event's classes.

  • In the same namespace as your aggregates?
  • In a sub-module like <aggregate-namespace>.Events?
  • Or a hybird: same namespace but a physical Events subdirectory

It's not a big concern but it would be nice to know what some of you did and how it worked out.

Thanks in advance!

Was it helpful?

Solution 2

For my service bus messages I have a separate assembly (being in the C# world) along the lines of MainNamespace.Messages. Any domain events that need to go across the wire would be in that assembly also.

If, however, you intend mapping the domain events to service bus events the domain events could be in the domain assembly.

OTHER TIPS

My understand is that the domain events should be in the domain layer (so the Domain project/assembly if you use .NET).

Where in the domain layer depends on how you structure the the project. Some do technical grouping, some do aggregate grouping).

Example (technical grouping):

Domain
📂 Events
   📄 InvoiceCreated
📂 Models
   📄 InvoiceModel
📄 OrderAggregate

Example (logical grouping by aggregate):

Domain
📂 OrderAggregate
   📄 OrderAggregate
   📄 InvoiceCreated
   📄 InvoiceModel

Then in the application layer you place the domain event handlers.

Application
📂 Controllers
📂 EventHandlers
   📄 InvoiceCreatedHandler
📂 Models
📂 Views
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top