- From: Stephen R. Savitzky <steve@crc.ricoh.com>
- Date: 21 Jul 1998 10:34:04 -0700
- To: Ted Bashor <bashor@crossroute.com>
- Cc: www-dom@w3.org
Ted Bashor <bashor@crossroute.com> writes: > Stephen R. Savitzky wrote: > > > > o There is no type-safe way to convert a Node to any of its major > > subclasses. The newly-added nodeName, nodeValue, and attributes > > attributes help a great deal, but it would be good to have conversion > > methods as well. We have, e.g., "asElement", which returns the node if it > > is an Element, null otherwise. This is _much_ more efficient than > > casting, which involves run-time type checking in Java. > > I would think that this API would be an extension useful in an > implementation that optimized specifically for Java runtime speed. > However I'm guessing that the average consumer of the DOM is probably > going to be happy enough with their language's default type checking > mechanism. Some languages don't _have_ a type-checking mechanism -- C++ is an example. Also, the construct in question allows the user to skip the extra step of checking the nodeType in many cases, so it's a speedup in _any_ language. > The only reason I object to having it in the core spec is that from an > OO point of view it is kind of ugly to have base classes A) know about > all or even any of their subclasses B) have to be modified when a new > subclass comes along. I agree that it's ugly, and I wouldn't have suggested it except that the set of core node type interfaces is small and fixed (or, rather, it would be fixed if there were a Declaration subclass), and that the Document interface already has a corresponding set of "create" operations. The latter is the most telling -- the DOM has already started down that path; one might as well do it right. Unfortunately, none of the common strongly-typed languages have constructs that allow one to do this kind of thing correctly. -- 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 13:29:36 UTC