W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1998

Re: latest DOM spec 19980720

From: Stephen R. Savitzky <steve@crc.ricoh.com>
Date: 21 Jul 1998 16:09:47 -0700
To: Ted Bashor <bashor@crossroute.com>
Cc: www-dom@w3.org
Message-ID: <qchg0ahkck.fsf@gelion.crc.ricoh.com>
Ted Bashor <bashor@crossroute.com> writes:

> I wouldn't say that having to update a factory class (Document) to
> accommodate a new subclass violates OO principles to the same degree as
> having to update a base class to accommodate a new subclass.

There are many who would say that it's the cast operator that violates OO
principles, and many others who would say it's a bad idea to migrate
operations (like getAttributes) into a base class in order to avoid it.

I've actually been down that route; an earlier version of our software had a
single Node-like class that could represent any SGML object.  The DOM seems
to be moving in that direction, come to think of it.  I believe it may be
possible at this point to represent an entire document using only an
implementation of Node, with the "attributes" attribute containing any
subclass-specific attributes (in the IDL sense).

There's still a certain amount of merit to such an approach; it essentially
lets you emulate the kind of weakly-typed language (like Lisp or Smalltalk)
that SGML systems have traditionally been built with.

The correct solution to the casting problem is probably to put all the
implementation-specific knowledge into specialized iterators (which can be
built knowing the implementation classes rather than just the interfaces).
Oh, well; that's exactly the course I took about a month ago.  My version of
a NodeIterator has a ``current Node'' and methods that return it as any of
the relevant subtypes.

-- 
 Stephen R. Savitzky   Chief Software Scientist, Ricoh Silicon Valley, Inc., 
<steve@rsv.ricoh.com>                            California Research Center
 voice: 650.496.5710   fax: 650.854.8740    URL: http://rsv.ricoh.com/~steve/
  home: <steve@starport.com> URL: http://www.starport.com/people/steve/
Received on Tuesday, 21 July 1998 19:05:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:45 GMT