Re: Subscriber callback interface design

From: David Rubin (fullname_at_warpmail.net)
Date: 05/16/04


Date: Sun, 16 May 2004 16:35:34 GMT

Denis Remezov wrote:

[snip]
> In this case, to avoid overdesigning, I would probably keep the original
> EventHandlerInterface and change RegisterEvent/UnregisterEvent to accept
> just a pointer to the interface without the event type (all HandleEvent__s()
> will be called).
> Compared to your more general solution, this design is quite simpler:
> - an implementation of EventHandlerInterface does not need to do
> dispatching (a big relief);

This is a very important point. In general, clients should be able to
register handlers on a per-event basis. This goes a long way towards
insulating clients from changes to the Event interface.

> - EventHandlerInterface doesn't care about EventTypeEnum;

And It shouldn't be as event handlers are only called for the types they
are registered for (and parameterized by event-specific data types if
necessary).

> - event data types do not need to have a single base class (no, they may
> happen to have nothing in common);
> - registration is much easier;
> - there is less coding.

One thing you might want to consider is allowing clients to register
event handler functors rather than event handler objects. This allows
you to 1) use free functions as an event handler while at the same time
2) use a (pointer-to) member function, but avoid multiple inheritance
(of MyBase + EventHandlerInterface) in your class hierarchy.

/david

-- 
"As a scientist, Throckmorton knew that if he were ever to break wind in
the echo chamber, he would never hear the end of it."


Relevant Pages

  • Re: Memory Leak due to objects not destroyed
    ... I checked and there was no direct event handler on a long lived object. ... The result is not bad (even if not really good for my memory leak): ... does the problematic form register an event ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
    ... I understand your concern over the design Michael, ... This will create the attribute, register the event, and all is well... ... Opera, etc.) to my handler, BUT, also, also pass it along to IE (cause it is plain anoying to have to retrieve it inside every single event handler on my page, if I can pass it instead) ...
    (comp.lang.javascript)
  • Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
    ... I understand your concern over the design Michael, ... This will create the attribute, register the event, and all is well... ... registration" call, to register the events in Moz, Opera, IE, etc. ... arguments passed to my "event handler wrapper"... ...
    (comp.lang.javascript)
  • RE: Triggering Events on <asp: RadioButton Help.
    ... you register the ItemCreated event handler in the ... > block so that register it evetytime the page is request. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)