I've been reviewing an example of domain event design blogged about recently by Mike Hadlow and created originally by Udi Dahan.
Currently we are publishing static events on our domain objects and subscribing to them directly within our services, or via our plugin model (we locate and initialize our plugins at runtime using StructureMap).
What is the advantage of using Udi's design?
From stackoverflow
-
It helps to avoid memory leaks caused by not deregistering event handlers when using C# built-in events.
Ben : But i'm right in thinking we could just detach the event handlers and this will achieve the same thing?Szymon Pobiega : Yes, you would achieve same results. To me it's just a matter for style: some people prefer built-in events and some prefer Udi-style with handler-per-class. In my opinion the advantage of the latter is it allows for a more decoupled design: event subscribers doesn't reference any static class directly. But for others this could be a disadvantage.
0 comments:
Post a Comment