W3C home > Mailing lists > Public > public-geolocation@w3.org > April 2010

Parameter style

From: Robin Berjon <robin@robineko.com>
Date: Wed, 7 Apr 2010 16:58:10 +0200
Message-Id: <60A2458B-6F5A-4B61-ACC4-EFC7B57F3886@robineko.com>
Cc: public-device-apis@w3.org
To: public-geolocation@w3.org
Dear Geo WG,

I am writing to you on behalf of the DAP WG. We have been discussing various styles of parameter passing for our APIs, and there is a tendency to lean towards the object literal style. However we noted while discussing this that that isn't the approach you had taken. This mostly concerns API calls that involve callbacks (of which we have many).

To provide examples, you have APIs set up like this:

  navigator.geolocation.getCurrentPosition(successCB, errCB, { option: "foo", option2: "bar"});

Since the error callback is optional, but options are useful, this leads to things like:

  navigator.geolocation.getCurrentPosition(successCB, null, { option: "dahut" });

We were thinking about going to full object literal:

  navigator.device.doSomethingCool({ success: scb, error: ecb, dahut: true, unicorn: false });

Our question isn't "what do you prefer?" as we'd like to avoid a cross-list discussion about who likes which style best but rather "did you discuss these differences, and if so what motivated your choice and can we please have a pointer to that discussion?" (I looked in the archives but didn't find it). If you had a rationale we'd be very interested in hearing it, and if you didn't (e.g. because that just happened to be the shape of what was proposed and no one complained) that's fine, we'll make our own.

Thanks a lot!

PS: Tracker, you owe me a cookie for ACTION-120.

--
Robin Berjon
  robineko  hired gun, higher standards
  http://robineko.com/
Received on Wednesday, 7 April 2010 14:58:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 22 March 2012 18:13:46 GMT