[Arp] Central dispatcher

Aral Balkan aral at ariaware.com
Wed Apr 20 08:04:21 PDT 2005


[I have no idea why this went directly to Chris... sorry about that!]

Hi Chris,

I can see several issues with this: First and foremost, I still don't
see the advantage of violating encapsulation. An event is a trait of an
object and should be a first-class citizen just like methods and
properties. By violating encapsulation, we open ourselves up the usual
problems: eg. What happens when there are event name conflicts?  Also,
we  create yet another dependency in the framework. Since we can already
couple data with events if we so desire, what is the additional benefit
of violating encapsulation in this instance?

All the best,
Aral

>Isn't this because events are registered as:-
>
>      object.addEventListener('GotUserProfile',doSomethingWithUserProfileFunction);
>
>and dispatched as:-
>
>      object.dispatchEvent({type:"GotUserProfile", data:userProfileVO});
>
>instead of , something like:-
>
>      EventManager.registerEvent("GotUserProfile",object);
>
>and 
>
>     EventManager.dispatchEvent({type:"GotUserProfile", data:userProfileVO});
>
>and so EventManager sends the event GotUserProfile object (or a copy
>of it) to all the objects that have registered interest in events of
>that type?
>  
>





More information about the Arp mailing list