W3C home > Mailing lists > Public > public-device-apis@w3.org > October 2009

RE: What does it all hang off of?

From: Tran, Dzung D <dzung.d.tran@intel.com>
Date: Fri, 2 Oct 2009 10:46:31 -0700
To: Robin Berjon <robin@berjon.com>, "public-device-apis@w3.org" <public-device-apis@w3.org>
Message-ID: <753F67ADE6F5094C9F1DBA00D1BAA8D312C3A7E791@orsmsx501.amr.corp.intel.com>
My opinion about this issue: it should hang off of navigator.platform or better yet: just platform. Hanging it off of navigator implies that Contacts actually are associated with the browser, which they are not. They are associated with the platform.  

Hence, platform.contacts.findOne().

My second choice would be to hang contacts off of device, like #4 below.

-----Original Message-----
From: public-device-apis-request@w3.org [mailto:public-device-apis-request@w3.org] On Behalf Of Robin Berjon
Sent: Friday, October 02, 2009 05:33 AM
To: public-device-apis@w3.org
Subject: What does it all hang off of?

Hi all,

one issue we have with APIs is also how they are exposed. Say for  
instance that the Contacts API has a basic interface providing access  
to the rest of the functionality called "Contacts". We could:

1) Make it available as a constructor:

   var cs = new Contacts();
   var mum = cs.findOne({ nickname: "mum" });

This pollutes the global namespace (since "Contacts" is now a variable  
in that scope), and is useless since there's no use for multiple  
instantiation of that class.

2) Make it available as an object already instantiated in the global  
scope:

   var mum = contacts.findOne({ nickname: "mum" });

This is nicer, less useless, but still polluting. Given the number of  
APIs that we have, it's probably a bad idea.

3) Make a way of requesting that an API be "loaded":

   var mum = loadAPI("contacts").findOne({ nickname: "mum" });

This adds only one item to the global scope (which is acceptable), but  
isn't idiomatic.

4) Use an object to provide access to all the device APIs:

   var mum = device.contacts.findOne({ nickname: "mum" });

I think the latter is the cleanest option. Specifying one such  
extensible object is trivial, and would be a very short specification.

Another option is to hang off of the navigator object just like  
geolocation did - but that seems wrong (I'm not sure why it was chosen  
there).

Thoughts?

-- 
Robin Berjon - http://berjon.com/
Received on Friday, 2 October 2009 17:47:15 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:53:39 UTC