In the example, the canvas, or some other part of your drawing
framework is calling Paint() on the MyControls. At some point, you're
calling into these objects from the outside, right?
Doesn't matter if the subclass is calling the superclass's method;
you still can't take an opportunity to act both before and after the
overridden method call.
Sub Canvas.PaintEverything
Dim CustomControl As MyCustomControlParentClass
For Each CustomControl In Self.ControlList
CustomControl.PaintBefore
CustomControl.Paint
CustomControl.PaintAfter
Next
End Sub
Note that you only need to add PaintBefore and PaintAfter to the superclass
and modify your function that starts the painting process if all you were
looking for was to do some special effects work before/after on OS X.
This also gives you the advantage of being able to turn off your special
effects for some controls by overriding PaintBefore and PaintAfter.
What if you're using Events and you find you don't want a particular control
to have the before/after effects? In other words, what happens in the
reverse situation where the subclass needs to act before, or otherwise
preempt, the standard behavior of the superclass? The point-of-control
problem can travel both directions on the chain. Of course it's solvable by
various means using either mechanism, and rarely comes up with proper
planning.
This debate reminds me of the goto debates. "One should NEVER use goto." I
hadn't used it in years until one of these debates came up on this list,
then I found it helped me clean up a couple fuctions, making them *easier*
to follow and modify. Not often, but sometimes it helps.
But had I been absolutely, religiously convinced, I would have never even
tried.
Are Events better than overshadowing...er...overriding functions? (Dang
terminology of non-standard languages from my past showing up again...) In
some situations certainly, though I doubt the advantage would be large in
any case. You can model any problem either way. Are they better all the
time? Is that even provable? I doubt it. So why insist that everyone agree
that one method is best for all code, all developers, all time?
Events are probably under used and appreciated because overriding is the
mechanism used in every other language. But then, who cares if people use
the mechanism they learned and are comfortable with?
Daniel L. Taylor
Taylor Design
Computer Consulting & Software Development
[EMAIL PROTECTED]
www.taylor-design.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>