[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Can you step in the same Region twice?



Abstract: Recapping a verbal conversation with Heh, "stepper" should
be a message to Table, not a pseudo-constructor which takes a Table as
an argument.  The first is directly extensible in an object oriented
fashion, the latter is not.


The problem is that there is no way to implement a generic stepper--a
stepper which knows how to enumerate the elements of any Table.  The
generic Table Heh had in mind actually used some hidden protocol that
wasn't part of the abstract Table class.  This means that if someone
later creates a new valid subclass of Table, the stepper
pseudo-constructor would either not work or have to be manually
extended.  Good object oriented code should be extensible by making
new subclasses, without necessitating modification to existing code.
(Granted this is rarely achieved, however it is a good heuristic for
evaluating alternative designs.)  Heh points out that one could ask
the Table for its domain Region, and then enumerate the elements of
the Region, but the same argument applies there.

In short, it is part of the responsibility of the Table to provide a
means of enumerating its elements.  Although we could extend Table
with some other messages to do this, and then have the generic Stepper
use these messages, it seems more straightforwards for "stepper" to
itself be the new message for Table.  Tables which interally have
peculiar implementations would then find it straightforwards to
provide peculiar steppers for walking over these peculiar
implementations. 

If there is a subclass of Table which provides the hidden messages Heh
has in mind, and is in turn the superclass of many other Table
classes, then this semi-generic Table can provide a semi-generic
Stepper in response to the "stepper" message that uses these hidden
messages.

By analogy, all this applies also to stepping through the elements of
a Region.