On Jun 27, 2007, at 11:00 AM, Daniel Stenning wrote:
> On 27/6/07 16:41, "joe at strout dot net" <joe at strout dot net> wrote:
>
>> Once a subclass has done so, it is often not
>> expecting a further subclass to effectively yank its
>> implementation out
>> from under it and replace it with something else.
>> The event mechanism, thankfully, does not allow this.
>
> Well sometimes the subclass might want it this way, sometimes not.
> Surely it
> should be under the control of the subclass as to which way it
> wants its
> handler to be treated. Currently this decision is in the hands of
> the base
> class, which seems inflexible.
>
> Surely the better solution would be to provide a checkbox option in
> each
> event handler to optionally permit the event handler to be
> overridden in a
> subclass.
>
Except that, IIRC, if you want a further subclass to have the
"event", then don't "use" it in that subclass... or provide a "New
Event" to pass the event along the chain of command!
Example: If you drag a Canvas onto a window and name it
"cnvMyIcon", then you've made a Canvas subclass named
"cnvMyIcon" (which - coincidentally - has an instance named the same
at runtime.). It has an open event because Canvas defines one. If I
then make another subclass of Canvas, "DiceCanvas" (which allows you
to "roll" a 6 sided die), and you set the Super for "cnvMyIcon" to
DiceCanvas, then you have an inheritance hierarchy as:
Canvas <- DiceCanvas <- cnvMyIcon
So as long as DiceCanvas doesn't use up the Open() event (i.e. you
don't put any code in it), then cnvMyIcon will have an Open() event,
as will any subclasses of DiceCanvas. Otherwise, if you use the Open
() event in DiceCanvas, then you have to define a "New Event Open()",
and - in the Open() event for DiceCanvas - call the new Open() event,
in order for cnvMyIcon and other DiceCanvas subclasses to see an Open
() event.
>> If the subclass really is prepared to
>> have its implementation overridden by a further subclass, then it can
>> define its own event for its subclasses to implement.
>
> Sure, but that would proliferate more event names and methods,
> which is to
> my mind not elegant .
>
> Cheers,
> Dan
>
>
>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|