Question

I have been reading about Domain Events and have seen codes from Udi's implementation(http://www.udidahan.com/2009/06/14/domain-events-salvation/) ,Mike Hadlow (http://mikehadlow.blogspot.com/2010/09/separation-of-concerns-with-domain.html), Jimmy Bogard and Jason Dentler's implementation.

All in all I like the idea of events.

My questions is which layer should I add these components.

I am not going to use any BUS and all events will be handled in Synchronous fashion.

I guess the interface IDomainEvent , IEventHandler should go in Project.Core where rest of the interfaces are kept and accessed by all projects.

The Dispatcher (which is a static class) I believe should go into Project.Infrastructure.

I will create a new Project just for Handlers of domain events. lets say Project.EventHandlers.

I will use IoC (structuremap) to register all handlers.

The Events themselves as I see are based on Business Language and for that reason I believe should go to Project.Domain where all Aggregates are implemented.

Let me know if this is the right way.

My other confusion is on project references. Should Project.Domain reference Project.Infrastructure so that it can use the static Event Dispatcher.

Should Project.EventHandlers reference Project.Domain because It needs to know what events are there that can be handled.

I am planning to create a StructureMap Registry class in Project.EventHandlers that will be then BootStrapped in Global.asax.

If this has been talked before please point me to the link. I couldn't find one through Google Searches.

Was it helpful?

Solution

Are these projects or namespaces? There's an ancient and ongoing debate about fine-grained verses coarse-grained project structure. I'm in the coarse-grained camp. An assembly is a unit of deployment, not a logical layer, and the structure you are describing is better achieved as namespaces in a single project.

Having said that, your organisation looks sensible. My only change would be to put interfaces alongside their implementations rather than in Project.Core.

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