Sun's HotSpot
Ken Dickey
kend at apple.com
Fri Oct 9 21:20:31 UTC 1998
>Can someone sum up the
>advantages of a prototype-based inheritance model?
I'll take a quick shot at it. The tradeoff really becomes apparent with
different usage scenarios. If you make a lot of objects which all share
common characteristics, the class based model works fine. When you start
making a lot of idiosyncratic objects, having a class per object makes
much less sense.
I did not really see the advantage of the prototype approach until I
started working with Apple's SK8 (pronounced 'skate') multimedia IDE.
The SK8 environment presents the author/programmer with a bunch of
pallets. So instead of building up from the bits, you typically make a
clone or child of a fairly heavyweight prototype object. Children can
inherit from multiple parents. It is kind of a grab, drop, add behavior
scenario. Like grab a window frame, grab a movie, grab some background
picture, grab a few sounds, make some hotspots play sounds and movies,
etc. Hook things up and add behaviors (methods) and you have a MM
application. You can change a 'parent' and either propagate changes to
children or not. When you open/inspect an object, you see both it's
state (ivars) and behaviors (methods), so you tend to think of dealing
with individual objects.
Note that there is a big change in level here. As I noted, the media
authoring objects tend to have most of what you need and therefore be
fairly heavyweight (i.e. have a lot of ivars and methods). This
Authoring level can be built on top of an underlying class based system
given some introspection and reflection. Instance methods are a great
help.
You may have noticed by now that Morphic shows some tendencies in this
direction. Heh, heh. ;^)
Cheers,
-KenD
More information about the Squeak-dev
mailing list
|