webtier@glassfish.java.net

Re: JSF 2.0: Errors or Ambiguity in Spec for "onevent" JavaScript Callback

From: <webtier_at_javadesktop.org>
Date: Wed, 30 Sep 2009 16:20:21 PDT

> We had to adopt best practices as part of our
> development process - the best practices that I've
> chosen to follow come from Crockford's excellent
> "JavaScript: The Good Parts".
>
> This is one of those best practice recommendations -
> it aids code readability, since it disambiguates
> function statements and function expressions.

Well, who am I to argue with an expert like Crockford? This is an interesting idea, and I need to read his argument for it. Still, empirically, I haven't observed that it has yet become standard practice to use
  var foo = function foo(...) { ... }
instead of the shorter and equivalent
  function foo(...) { ... }

I have never used YUI, which presumably uses this form. But none of jQuery, Prototype, Scriptaculous, Ext-JS, or Dojo follow this style, either in their online examples or in their source code. However, YUI is famous for better preparing for mixing with other libraries and handling other code without name conflicts, so this idea is worth looking at.

> I really can't say enough about Crockford's book -
> it's almost as good as the classic K&R.

My "best practices in JavaScript" reference has been "Pro JavaScript Techniques" by John Resig (of jQuery fame). But the Crockford book sounds like a must-read, so I just ordered it. Thanks for the tip!

Cheers-

- Marty
http://www.coreservlets.com
[Message sent by forum member 'martyhall' (hall_at_coreservlets.com)]

http://forums.java.net/jive/thread.jspa?messageID=366404