David Rettenbacher
David Rettenbacher

Reputation: 5120

DDD: Where to Place Domain Events

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

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!

Upvotes: 3

Views: 2561

Answers (2)

Fred
Fred

Reputation: 12826

My understanding 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

Upvotes: 3

Eben Roux
Eben Roux

Reputation: 13256

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.

Upvotes: 1

Related Questions