Re: addEventListener naming

Hi, Jonas-

Thanks for your feedback.  I'd like to hear from other implementers, but 
your reasons seem sound.

Jonas Sicking wrote (on 9/12/09 5:21 PM):
> On Sat, Sep 12, 2009 at 1:19 PM, Doug Schepers<schepers@w3.org>  wrote:
>>  Hi, Alex-
>>
>>  I've tentatively added the 'listen()' and 'unlisten()' methods as syntactic
>>  sugar shorthands for 'addEventListener()' and 'removeEventListener()'.
>>    Obviously, this assumes that the implementers have no objections, and are
>>  willing to implement these methods.
>
> For what it's worth, I would rather not implement these new methods in
> Firefox, for the following reasons:
>
> 1. As far as I can tell it has not been shown that the developer
> community at large sees the long name as a significant problem.
> 2. If the long name is a significant problem, then it can easily be
> worked around in JS by using prototypes. As far as I know no library
> does this, further indicating that this isn't something that
> developers find to be a bug burden. (In fact, if we should 'rename'
> any method, it would be to rename 'document.getElementById' to '$').

Personally, I would love to rename the awkward 'addEventListener()', 
'removeEventListener()', 'getElementById()', et al, methods, but I also 
understand wanting more descriptive names.


> 3. There's a better suggestion in this thread for how to get rid of
> the extra argument; simply mark it [optional].

That's also an option.  I am leaning toward switching to Web IDL soon, 
so we could do that then.


> 4. More methods for the developer community to learn. While learning
> both isn't needed to write code, it is needed to read other peoples
> code. Ability to read and understand other peoples code is a major
> strength of the web platform.

Agreed, but we already have a proliferation of new shorthand method 
names through script libs... might it not be better to have some 
standard shorter names that are better documented?

Regards-
-Doug Schepers
W3C Team Contact, SVG and WebApps WGs

Received on Saturday, 12 September 2009 21:37:56 UTC