Welcome to MSDN Blogs Sign in | Join | Help

Dave Massy's Blog

Embedded Windows

Syndication

What's in a name?

There's a little debate going on in the WebAPI working group at the W3C about the naming of some methods.

The proposed names in the Selectors API spec include match() and matchAll(). Feedback was given to the WG that this was a too generic and it would be better to have descriptive names such as getElementBySelector/getElementsBySelector that follow the names of existing DOM functions of getElement(s)By*. This was met with initial resistance and there's certainly a good argument for keeping names short. However having consistency of naming and having the name describe the functionality is something we believe is important.
Many tools now offer auto-complete and developers may type "get" and see a drop-down of available methods on the object that start with those letters. Experienced web developers may not use those development techniques but an increasing number of less experienced developers for whom speed of development is essential do use these tools to help them find the functionality they are looking for. Consistent naming helps deliver a better developer experience. We all know that developers rarely look at the API documentation in the same way that I only get around to looking at the instruction manual for a new gadget if I'm completely at a loss for how the thing works.

It looks like public feedback at http://lists.w3.org/Archives/Public/public-webapi/2006Dec/ and on Anne's post would agree that a descriptive name is important. Although there are certainly people who want to save themselves a few keystrokes as well and would be happy calling something foo().

Of course as has been pointed out we haven't been super consistent in the past around naming. However the argument that we haven't been consistent or good about names in the past is a poor reason for failing to try to be consistent in the future. There is probably not such thing as the perfect name but we should at least strive for the best we can come up with.

Thanks
-Dave

 

Published Thursday, December 21, 2006 12:22 PM by DMassy

Comments

# re: What's in a name? @ Friday, December 22, 2006 4:31 AM

I have been following the discussion after Anne's post and am quite in favor of the getElementsBy* naming convention.

Autocomplete support is, in my opinion, not a compelling argument in favor of the longer naming. But I do believe that consistent and descriptive naming are very important.

The way methods are named is something of a face or a businesscard of a programming language. Peoples first impression of javascript/domscripting might not always be very pleasant but at least the naming of most things is clear. (Allthough the IE specific extensions are very confusing for javascript beginners).

Something to keep in mind when writing a spec is that future programmers (withouth previous javascript or even any programming experience) should be able to pick up the language and run with it.

Jaap

# re: What's in a name? @ Saturday, January 06, 2007 1:56 PM

What is a person supposed to do about existing applications that break when IE 7 is installed?

Please read http://www.dotnetjunkies.com/WebLog/mwherman2000/archive/2007/01/06/183736.aspx

Not impressed ...tabs is not a good trade-off for broken backward compatbility

Michael Herman (Parallelspace)

New Comments to this post are disabled
Page view tracker