views:

31

answers:

1

Hello,

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 later 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

Please advise.

Mar

+1  A: 

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.

Mike Hadlow
@Mike- Thank you for the reply. I had the projects as different assembly and you have made me rethink some of these assemblies ( if not all) as namespaces, which I think will lead to simpler implementation. Said that, how can I achieve lose coupling if Interfaces are put alongside their implementation? By having them in a different assembly I was referencing core in MY MVC app as well as Services layer.
TheMar