Re: Selectors API naming

On Wed, 20 Dec 2006 19:13:08 +0100, Charles McCathieNevile  
<chaals@opera.com> wrote:

>
> On Tue, 19 Dec 2006 17:51:37 +0100, Charles McCathieNevile  
> <chaals@opera.com> wrote:
>
>> 1. Does anyone see any other issue in the current draft that should be  
>> fixed?
>
> I'm happy...
>
>> 2. For the following options, do you consider the names "fine", "not  
>> great but acceptable", or "unacceptable"?
>>       getElementBySelector/getElementsBySelector
>>       matchSingle/matchAll
>>       matchSingleBySelector/matchAllBySelectors
>
> (note the correction to the above :( Thanks Bjoern).
>
> Any of these is OK by me. I also like Berjon's "matchCSS" approach to  
> naming. Mostly, I still like names as short as possible, and shipping...
>
> cheers

Just butting in here, feel free to continue after my ramblings:

1. Being consistent is always good, even if it leads to long function  
names. There are limits of course. This favours "geElementBy#?".

2. The getElementBySelector seems to me as something that uses CSS  
selectors to get a subset of a DOM tree. Is this kind of selection  
supported in other places of DOM? Would it be clever to clearly note that  
the selection is done using CSS type of selector, or is the term  
"Selector" enough to show that this is different to any possible future  
ways of getting a subset of the tree? (This might favour  
"(match#?|select#?)CSS"

3. I guess the most correct name would by getElementsByCSSSelector, or  
even getElementBySelector("CSS",...)

4. I think keeping short names is only good in a short-term way (polluting  
your available namespace, making ambiguous symbols etc.) I don't think  
"letting developers type less" is a very good argument in favour. There  
are tools (auto-completion, auto-generating code) and preprocessors or  
languages supporting macros or function pointers/references if it's really  
necessary to type less.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Received on Wednesday, 20 December 2006 18:53:05 UTC