W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1999

Re: DOM L2 comments, various

From: Tim Taylor <tim.taylor@iname.com>
Date: Thu, 7 Oct 1999 17:15:46 -0400 (EDT)
Message-ID: <37FD0D58.F7E5249@iname.com>
To: www-dom@w3.org
Arnaud Le Hors wrote:
> John Cowan wrote:
> >
> > Au contraire.  I believe that using instanceof for type discrimination
> > (as in, if (x instanceof Element) do_this else if (x instanceof Attr) do_that)
> > is the worst kind of bogus OOP.  My implementation makes zero
> > guarantees about underlying classes, how many or with what crossovers.
> Well, I disagree, but it's ok.

I also disagree, but that's irrelevant because there are other kinds of
"non-bogus" OOP that do type descrimination without instanceof that
would also break.  Namely, I'm thinking of the technique "double
dispatch" most commonly used by the Visitor design pattern.  Of course,
since using the Visitor pattern requires that you write your own
implementation, it's kind of moot.

Speaking of which, can anyone address whether Visitor was considered for
inclusion in the DOM 2 as another Traversal mechanism, and if it was
considered, why it has been omitted?  I posted a more comprehensive
question in August that was never replied to:


Of course, I suppose I can answer my own question: that loosely typed
languages like ECMASCript can't perform double dispatch.  Any other
reasons for omission?


> > BTW, I don't see how you can implement all HTML*Element interfaces with
> > one class in Java, since some of the instance methods have incompatible
> > return types, and Java doesn't allow overloading on the return type.
> > I needed IIRC six classes.
> Same here, that's why I said "_Basically_ all the HTML*Element
> interfaces were implemented on the same class." ;-)
> --
> Arnaud
Received on Friday, 8 October 1999 04:02:46 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:06 UTC