[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Delegating to Sender
When implementing partially polymorphic delegatee classes as described
above, it can be useful to have certain messages forwarded to the
delegator automatically. For example, if a TextWindow class delegates
messages to a TextBlock class, the TextBlock may need to obtain the
coordinates of the delegating window. These can be obtained using
expressions such as SENDER():nTop. However, if a subclass of TextBlock
were defined, the implementor of the subclass would need to know that it
should obtain these values from the sender. This situation can be improved
by defining messages or variables in the TextBlock class that are
forwarded to the sender, for example:
VAR nTop TO SENDER
This allows subclasses of TextBlock to send the nTop message to self,
instead of SENDER(), to obtain the required value. The implementor of the
subclass no longer needs to know which messages or variables are actually
defined in the delegating class.
Warning
As always with partially polymorphic delegatee methods, they should only
be invoked via delegation. A method that relies on messages that are
automatically forwarded to the sender, as in the above example, will
behave incorrectly if not invoked via delegation.
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson