W3C home > Mailing lists > Public > public-webapi@w3.org > January 2007

Re: Selectors API naming

From: Simon Pieters <zcorpan@gmail.com>
Date: Thu, 25 Jan 2007 21:30:32 +0100
To: public-webapi@w3.org
Message-ID: <op.tmp8k60p7a8kvn@hp-a0a83fcd39d2>

Hi,

On Thu, 25 Jan 2007 19:26:38 +0100, Anne van Kesteren <annevk@opera.com>  
wrote:
> So the WG just discussed in a little over an hour a counter proposal to  
> the current naming[1] and came up with:
>
>  * getElementBySelectors()
>  * getElementListBySelectors()

I like get() and getAll() much better. They are shorter, more convenient  
and less likely to be typoed, especially the getElementListBySelectors  
(which tends to become getElementsListBySelectors or something).

get() is very straightforward, and anyone seeing a JS snippet like the  
following:

    var e = document.get("#nav ul");

....will immidiately understand what it does. It's true that they will  
probably also understand:

    var e = document.getElementBySelectors("#nav ul");

....but that's 18 characters longer, and from what I've heard and from  
personal experience, JS authors are already fed up with the  
getElementsByTagName() and getElementById() methods, being too long and  
hard to type.

Robert Sayre gave my permission to quote him from IRC:
> [20:48] <sayrer> wow, annevk
> [20:48] <sayrer> those names suck!
> [21:02] <zcorpan> sayrer: what names?
> [21:02] <sayrer> getElementsListBySelector
> [...]
> [21:03] * zcorpan likes get and getAll better
> [21:03] * sayrer notes that I got it wrong

Regards,
-- 
Simon Pieters
Received on Friday, 26 January 2007 04:51:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:56 GMT