W3C home > Mailing lists > Public > public-webplatform@w3.org > October 2012

Re: JavaScript/ECMAScript Styling and Citation

From: Pete L. <plamoni@gmail.com>
Date: Wed, 17 Oct 2012 15:18:53 -0500
Message-ID: <CADRHs0hpwEMGOF1TtiVrXe-wktFkCT9wRtHJQW_nXCHsqRGFyQ@mail.gmail.com>
To: "WebPlatform.org" <public-webplatform@w3.org>
Not sure if we'd be creating "yet another style guide" or not. Sure, it's
easy to find "JavaScript style guides", such as the following:


However, these guides are focused on writing re-usable, maintainable,
proper production JavaScript application code. Our goal is somewhat
different. For instance, none of the above guides has anything to say on
the subject of denoting evaluated JS (see my earlier post).

Additionally, none of the guides denote a common set of reusable variable
names. For instance, refer back to the MDN Values, Variables, and Literals


The first example uses the variable "answer", the second uses "x" and "y"
then it goes on to use "a", "b", "input", "myArray", "n", "myvar",
"prefix", "f", "g", "coffees", "fish", "myList", "Sales", "car", "foo",
"quote", "home", "str", and then "x" again. My point is that there isn't
even a consistant capitalization style here, much less a common set of
standard variables. I don't know that this really matters in the long run,
but I think it goes towards consistency to use similar "throwaway
variables" across all example code.

I guess the DOJO guide goes into class naming conventions, but it's more
oriented towards substantial code-bases than short snippets of example code.

So, what I'm thinking is not necessarily a style guide that talks about
things like the use of "===" vs. "==", or the use of single-quotes vs.
double-quotes. Those can be addressed by selecting an existing guide from
one of those above (my vote is for jQuery's, as it's short, simple, and to
the point). However, I think that we should supplement with a guide on
variable naming, expression-value commenting, and anything else we
determine should be addressed specifically to bring consistency to example

Maybe I'm being a bit to anal-retentive and/or dictatorial here.


On Wed, Oct 17, 2012 at 11:25 AM, Tobie Langel <tobie@fb.com> wrote:

> On 10/17/12 2:28 PM, "Andrew Rowls" <eternicode@gmail.com> wrote:
> >> TBH, It's unenforceable unless there's proper tooling. I'd leave it
> >> open and have a page discussing the various styles pros and cons.
> >
> >Though technically unenforceable (for now?), I think it would still be
> >beneficial to have official guidelines to point people to.  A discussion
> >on pros and cons is well and good, but flavor-of-the-week style in
> >examples would just be confusing.  Better to have a little official
> >consistency and something to back it up than to have no consistency.
> Fair enough.
> >> I strongly favor vi, here.
> >
> >When did this become about editors? :P
> :D
> --tobie
Received on Wednesday, 17 October 2012 20:19:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:13:32 UTC