AggregateRoot.Apply() in event sourcing-branch

Oct 19, 2010 at 5:32 PM

Hi,

first of all, thank you very much for this sample. It's a nice piece of code and it helped me a lot in understanding cqrs and event sourcing. But there are two things in the event sourcing branch that I don't understand. Both are related to the private Apply() method in the DDDSample.Domain.AggregateRoot class. First, why do you call these On*() methods? If an entity should be notified about them why don't you just use Bus.Register()? Second, why do you use reflections? This seems kind of dirty ;) to me... Why don't you use e.g. overloads of say AggregateRoot.OnEvent(Event e) or something like this?

Thank you!

Coordinator
Nov 22, 2010 at 5:48 AM
Sorry for such a late answer. I was very busy last few weeks/months.

2010/10/19 Al3x3 <notifications@codeplex.com>

From: Al3x3

Hi,

first of all, thank you very much for this sample. It's a nice piece of code and it helped me a lot in understanding cqrs and event sourcing. But there are two things in the event sourcing branch that I don't understand. Both are related to the private Apply() method in the DDDSample.Domain.AggregateRoot class. First, why do you call these On*() methods?

This thing is a mental shortcut from registering each entity (for each of its events) in the EventBus (as you mentioned below). Instead of explicitly registering each event, I made a convention that if method starts with On and accepts a single parameter, it is an event handler and should be wired with an appropriate event. This is better ilustrated in NCQRS framework, where you can have different event registration strategies (among which there is a similar to mine, but there are also other as well).

If an entity should be notified about them why don't you just use Bus.Register()? Second, why do you use reflections? This seems kind of dirty ;) to me... Why don't you use e.g. overloads of say AggregateRoot.OnEvent(Event e) or something like this?

Reflection is a necessity here I believe. Overloads early-bound so they can't help when the code gets an event (as an Object) and has to route is to the appropriate subscribers.

Hope that helps
Szymon

Thank you!

Read the full discussion online.

To add a post to this discussion, reply to this email (dddsamplenet@discussions.codeplex.com)

To start a new discussion for this project, email dddsamplenet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com