BlingBag icon indicating copy to clipboard operation
BlingBag copied to clipboard

Q: implementation

Open zygimantas opened this issue 8 years ago • 5 comments

Hi, a lot of time passed after the creation of this project. Do you still consider it is the most elegant way to implement domain events with c#? Do you have any other updates or recommendations? Thanks in advance.

zygimantas avatar Mar 01 '16 12:03 zygimantas

@bsommardahl , I also miss IBlingInitializer and sample implementation, mentioned in this article: http://awkwardcoder.com/2012/08/28/nhibernate-lazy-loading-blingbag/ (I am interested in situation where Lazy loading and NHibernate is irrelevant and fully initialized entities are retrieved from the repository).

zygimantas avatar Mar 01 '16 14:03 zygimantas

@zygimantas If you are triggering events from command handlers, then I would consider BlingBag the best way to do it. Most of the implementations of domain events use messy static classes. BlingBag uses normal c# events and handlers.

On the other hand, if you're triggering domain events using event sourcing, I would not use BlingBag.

Blingbag is still used in production and is implemented into new projects all the time. I know I don't maintain the code very often... that's true. :( But the project is still viable and in use.

I just checked on IBlingInitializer and I can't seem to find the implementation. I have a feeling it was replaced with something else, but somehow we didn't update the rest of the code-base. I'll see if I can check on that today.

bsommardahl avatar Mar 01 '16 14:03 bsommardahl

Thanks @bsommardahl I am planning to raise events from command methods inside domain entities without using event sourcing. I will be looking forward for your update, because this missing part prevents to see the complete picture.

zygimantas avatar Mar 01 '16 14:03 zygimantas

@bsommardahl any success finding the source?

zygimantas avatar Mar 04 '16 22:03 zygimantas

Yes. I believe it was removed because it was no longer needed. The job of the initializer was to subscribe to the events on a class using the dispatcher. So, instead of the extra service performing that "initialization", just subscribe to the events directly. I'm not at a computer right now or I would include a sample.

Assume your command handlers all have an event on them called "NotifyObservers". In your command dispatcher, before executing the command handler for a given command, "initialize" it by subscribing to like this:

NotifyObervers += domainEvent => _blingDispatcher.Dispatch(domainEvent);

That's all there is to it. Feel free to reply with more questions. I'll be back on the computer on Monday. On Fri, Mar 4, 2016 at 4:27 PM Zygimantas Berziunas < [email protected]> wrote:

@bsommardahl https://github.com/bsommardahl any success finding the source?

— Reply to this email directly or view it on GitHub https://github.com/bsommardahl/BlingBag/issues/1#issuecomment-192499866.

Byron Sommardahl CTO, Co-Owner Acklen Avenue | www.acklenavenue.com | 615-669-8239 632 Fogg Street Suite 8, Nashville, TN 37212

Acklen Avenue is a custom software development company committed to creating quality software that people love to use.

bsommardahl avatar Mar 05 '16 04:03 bsommardahl