3

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!

David Rettenbacher
  • 4,870
  • 2
  • 33
  • 40

2 Answers2

2

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
Fred
  • 10,269
  • 4
  • 48
  • 63
1

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.

Eben Roux
  • 12,009
  • 2
  • 23
  • 43
  • *(Better late than never)* I went with placing it in the domain assembly, thanks! Additionally I placed them in the same namespace as their aggregates. – David Rettenbacher Jun 26 '15 at 07:27