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

Re: Selectors API naming

From: Doug Schepers <doug.schepers@vectoreal.com>
Date: Fri, 05 Jan 2007 03:28:27 -0500
Message-ID: <459E0C2B.2030804@vectoreal.com>
To: alex@dojotoolkit.org, public-webapi@w3.org

Hi, Alex-

Alex Russell wrote:
>> document.matchAll is deviating from that.
>> Document.getElementsBySelector has a higher readability in that
>> regard I think.
> I disagree. It's perhaps easier to *introduce*, but it's actually harder 
> to read since it makes lines longer and therefore increases the need to 
> wrap them. 

It might just be my coding style, but I don't normally have many lines 
that wrap.

In any case, this is overcome by shortnaming, if line length is really 
that much of a concern.

> If you are looking to preserve the "this API handles 
> selectors" semantic, one could propose document.bySelector(), but I 
> think the argument that this or getElementsBySelector are better than 
> match() or matchAll() are weak.

Why do you think they are weak?

> Your argument revolves around introducing this new function name to the 
> global population of developers, and while I agree that it's a 
> considerable cost, it will be a sunk cost much sooner than the effects 
> of typing a longer name a billion times will be dissipated. Maciej's 
> argument that this will be a critical API and therefore deserves a 
> shorter name rings true with me in a way that optimizing for 
> introduceability doesn't.

I agree that the shorter the name, the better.  But I'm really concerned 
about losing the descriptive quality.  Newbies will learn the 
functionality of the name more easily if it is descriptive, and experts 
can alias it shorter if they wish.  I don't see where this loss of 
productivity is coming from.

Upon further thought, getElementBySelector/getElementsBySelector is a 
bad set of names, since it seems prone to typos.  What about something like:

  * document.getNodeByExpr()
  * document.getNodelistByExpr()


  * document.nodeByExpr()
  * document.nodelistByExpr()

Descriptive of the return value and the criteria, and not terribly long. 
  Feel free to sub in "Sel" or something else for "Expr".



Research and Standards Engineer
6th Sense Analytics
mobile: 919.824.5482
Received on Friday, 5 January 2007 08:28:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:22 UTC