W3C home > Mailing lists > Public > public-device-apis@w3.org > August 2011

Re: Contacts API -- [NoInterfaceObject]

From: Robin Berjon <robin@berjon.com>
Date: Wed, 24 Aug 2011 14:55:01 +0200
Cc: public-device-apis@w3.org
Message-Id: <54A5620A-1DFC-431E-98BD-70D7D8D04ECC@berjon.com>
To: Andreas Gal <gal@mozilla.com>
Hi Andreas,

On Aug 24, 2011, at 09:53 , Andreas Gal wrote:
> Can someone explain to me why all the classes in the Contacts API are marked [NoInterfaceObject]?
> This seems pretty non-standard behavior (most of the DOM doesn't behave like this).

I wouldn't work with the assumption that the DOM is necessarily the reference when it comes to API design. Large tracts of it seem to have considered JS as an afterthought (if at all) and it is formalised using OMG IDL instead of WebIDL  I'm not eve sure that the former supports a mechanism for NoInterfaceObject.

The idea behind using NoInterfaceObject is to avoid global namespace pollution unless there happens to be a good use case for exposing a given object (which there may well be, it might simply not have been suggested yet). We're clearly not the only ones using this approach:

    http://www.google.com/search?q=NoInterfaceObject+site%3Aw3.org+inurl%3A%2FTR%2F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a

> It breaks instanceof checks, and defeats extensibility (using expandos) via a shared prototype.

My understanding is that instanceof is too unreliable due to cross-context issues and that expandos on host objects were strongly discouraged (I certainly have been avoiding both). That being said, this is naturally open to discussion.

-- 
Robin Berjon - http://berjon.com/ - @robinberjon
Received on Wednesday, 24 August 2011 12:55:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:22 GMT