Event or call WorkItem method direct

Topics: CAB & Smart Client Software Factory
Feb 28, 2006 at 3:39 PM
originally posted by: sklett

I'm sitting here trying to determine if I should use EventBroker or make a call on my WorkItem direct. Here is the situation:

In my view if a user double clicks an item, I call a method of the presenter which in turns needs to let the parent(root) workitem know that it needs to do something.

At first this seemed like a perfect use for events, but then as I'm thinking about it... my presenter already has a reference to the workitem, why not just call workitem.FooBar()?

Anyone have some insight for me?

Thank you,
Feb 28, 2006 at 4:29 PM
originally posted by: matiaswoloski

Hi Steve,

As a general rule, I would use EventBroker. Events will always be more loosely coupled.
For example, suppose you have a change requirement that modifies the hierarchy of your WorkItems. Your Parent workitem might won't have the same responsibilities that has now. You might want to move the workitem to another module, and there you have a dependency between modules. If you would have used EventBroker the change wouldn't have affected so much.

This is an hipothetic situation, it always depends on your context.

Mar 1, 2006 at 10:49 AM
originally posted by: sklett

I understand, I think you are correct.
What I'm still getting used to is that deciding to go with CAB is a major commitment. Do stick to the patterns a lot of old habits need to be broken.

Thanks for the response, I appreciate it.
Have a good one,