Some comments about WorldClass


22 Aug 1995 02:32:04 GMT

Strangely enough, I've just been working on a Vehicle
implementation in WorldClass, and I have a few comments
to make about the design of WorldClass in the light of
my experience.

(1) Testing the type of an object using isclass() seems
to me a BAD idea, since it wires in behaviour that cannot
be overridden. The same effect can always be achieved
by testing a property instead, and this allows a subclass
to change the behaviour.

Initially I made my Vehicle a Nestedroom, which worked
except that it wouldn't let me put anything in it.
Digging further and noticing dire warnings in world.t
about attempting to subclass Nestedroom, I tried making
it just a Room.

But then I couldn't refer to it at all! Turns out that
the disambiguation code won't let you talk about anything
that's of class Room but not Nestedroom, and because of the
use of isclass(), this is non-negotiable.

So I either had to not make it a Room at all, and be
faced with reimplementing much of what Room provides,
or go back to making it a Nestedroom. I chose the
latter.

Then I had to override verDoPutin and verDoTakeout to
let me put things in/out of the Vehicle. According to
the manual, if you want a Nestedroom that can have
things put in it, you're supposed to put another class
in front to provide this behaviour.

But using the obvious choice, Container, for this purpose
does not work, because Nestedroom already inherits from
Container (via Room) and disables its put in/take out methods.
Which brings me to:

(2) I don't understand why Room needs to be a descendent of
Container rather than something higher up which never allows
put in/take out in the first place.

And a final comment about the manual: It's a good start,
although it needs more work before WorldClass can be used
without having to read the source. For instance, I had to
consult the source to find out that the Lockable class
has a 'key' property, rather than 'mykey' as with Doors.
A list of all the properties relevant to each class
(not just Thing) would be a considerable help.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of Japan Inc.|
greg@cosc.canterbury.ac.nz +--------------------------------------+