On Aug 21, 6:28 pm, Jarek Foksa wrote: > Here are the rules that I'm following when choosing names for > custom events (those are by no means standard): > - event name should start with 'on' word
My initial feeling, when starting down this road some years ago, was that an 'on' prefix would make event names nicely self-declaratory. That is, when someone started reading the code they would see the 'on' prefix and, guided by their experience with web browser object models, immediately think "event related". And they did, but unfortunately there was a reoccurring tendency to initially think "browser object model event related", particularly for events relating to similar concepts (e.g. resize, change, drop). Essentially the 'on' prefix for JS object event names proved just about equally as misleading as it was helpful. This suggested drawing a stronger distinction between browser object model events and custom events on javascript objects. Trying to retain the self-declarative aspects of event names but highlighting the distinction between the browser events and javascript object's events. After experimenting with some alternatives (such as requiring only camel case event names for JS object, which did not prove sufficient) I decided to change the prefix for JS object events from 'on' to 'when'. That requires an initial word of explanation but once the new programmers understand that that is the standard they are working with for all JS event names within our system they seem to be much better at knowing where to look in order to understand the behaviour they are interested in. This experience leaves me disinclined to agree with the "should" in "event name should start with 'on' word". Richard. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
