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

Re: Selectors API naming

From: Joćo Eiras <joao.eiras@gmail.com>
Date: Fri, 26 Jan 2007 05:26:14 -0000
To: "Simon Pieters" <zcorpan@gmail.com>
Cc: "Web APIs WG" <public-webapi@w3.org>
Message-ID: <op.tmqxd0w0jz3wb9@dragast>

Na , Simon Pieters <zcorpan@gmail.com> escreveu:

>
> 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.

I too like short names. That's why I write my own wrapper functions. If  
you really want to use get, write your own wrapper function, but get  
itself is not a descriptive name, and therefore is against w3c guidelines  
(me thinks). Following that line of reasoning, the specifications would  
start having short name for everything, like instead opf writing  
doucment.implementation.createDocument I'd write doc.i.cdoc. A  
unexperienced programmer will scratch his head wondering what it means.
The base specification must be descriptive, clear and well structured.
... (and now I started the debate again)... :p

> 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
>

Again, this is personal taste. I could say the same for any other name.

> Regards,
Received on Friday, 26 January 2007 05:26:15 GMT

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