On Aug 24, 2007, at 12:41 PM, Michael Geary wrote:
In JS, we already have a few pseudo-standard nomemclature,
for example a popular patten of starting functions with a
lowercase letter:
function initProcess()
I personally prefer using capitalized words for
processes/functions and lower case words for data.
Don't! In JavaScript, it's a standard convention to use initial
uppercase
for constructors and initial lowercase for all other functions.
Initial
uppercase will make everyone think you plan to use the function as a
constructor.
I totally agree with Mike here. In general, I think it's a good idea
to use the conventions that the language itself uses. Camel-cased
variables are what I prefer.
And finally, to bring this on topic :-) here is a jQuery-specific
naming
convention that I highly recommend. Use an initial $ on every
variable that
contains a jQuery object:
var $foo = $('#foo'), foo = foo[0];
$foo.show(); // jQuery
var id = foo.id; // DOM
It's always a good idea to cache a jQuery object instead of
repeating the
query or $() call over and over again, and the $ prefix is a good
visible
reminder that it's a jQuery object.
Yes, yes, yes! Even if it's only for your own sanity, I second this
recommendation. I can't remember who it was on the list who
originally suggested this idea over a year ago -- It was probably
Michael -- but whoever it was, I thank you wholeheartedly. This one
simple convention has made my jQuery coding (and, therefore, my life)
so much easier.
cheers,
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com