문제

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!

도움이 되었습니까?

해결책 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.

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top