Re: camelCase for event listeners

While this is probable low priority "camel vs no camel for events", it's 
better we pick something and stick to it before it's too late.

I guess the pro-camel case argument is:
- much easier for human readability
- consistent with remainder of API

and the anti-camel case for events augment is:
- consistent with "legacy / existing" APIs
- property vs event is a matter of prepending "on"

I've personally always been more in favor of an API being consistent 
with itself as the #1 goal. I've never much liked the all-lowercase 
events but I knew it was consistent with other APIs when we started 
drafting the API. The property vs event argument by just adding "on" in 
my mind only has merit if converting might be done programmatically vs 
by a human, as the human can know to follow the camel case rules when 
they code if that is the convention.

So do we buck the existing trend and put an end to difficulty in human 
readability? I prefer readable code more than anything and I do not mind 
long method names when it improves readability / understandability. So 
I'd lean toward making everything camel case despite it going somewhat 
against the existing grain.

-Robin

> Adam Bergkvist <mailto:adam.bergkvist@ericsson.com>
> April 10, 2014 at 1:32 AM
>
>
> Hi
>
> It seems to be a convention among web APIs using DOM events to keep 
> the event handler attribute names in all lower case. I agree that it's 
> not the prettiest thing in the world. I guess one reason is an other 
> convention to have event names, e.g. "canplay" (media element), in 
> lower case and the attribute name is simply the result of prepending 
> "on".
>
> BR
> Adam
>
> cowwoc <mailto:cowwoc@bbs.darktech.org>
> April 7, 2014 at 7:42 PM
> Hi,
>
> In reading http://ortc.org/wp-content/uploads/2014/02/ortc.html I 
> noticed that you use camelCase for all identifiers except event 
> listeners, which use all-lowercase names. I personally find lowercase 
> names harder to read, especially for longer names.
>
> Would you consider changing these to camelCase instead?
>
> Thanks,
> Gili
>

Received on Friday, 11 April 2014 13:24:15 UTC