Re: Contacts API -- [NoInterfaceObject]

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 UTC