JavaScript Convention Documents

M

Martin Rinehart

I asked Google for "javascript code conventions". He pointed me to
seven convention documents. (More exactly, to Crockford and six lesser
convention documents.) I have compiled all the conventions in a single
document, here:

http://www.martinrinehart.com/articles/javascript-conventions.html

I stress that these are NOT my conventions; this is a compilation of
the others. My job: clerk. I tried to be a good clerk, organizing
sensibly so you can find things easily. Not always easy in a field
descended from Sun's Java conventions.

I was frankly disappointed to see that from all the available naming
styles (UpperAndLower, lowerAndUpper, ALLCAPS,
lower_with_underscores, ...) JavaScripters do almost nothing to use
these in an intelligent way. We should have conventions, as Java does,
that let you see immediately that you are looking at an object
reference, public method, etc.

For what it's worth, 6 conventions say JavaScript, one says
Javascript. None use anything else.

I'd like this thread to stick to the document (fixes, documents I
should include, ...) If you want to argue for or against particular
issues, please focus on the issue in a separate post. I'll set things
off in my next post.
 
D

David Mark

I asked Google for "javascript code conventions". He pointed me to
seven convention documents. (More exactly, to Crockford and six lesser
convention documents.) I have compiled all the conventions in a single
document, here:

http://www.martinrinehart.com/articles/javascript-conventions.html

I stress that these are NOT my conventions; this is a compilation of
the others. My job: clerk. I tried to be a good clerk, organizing
sensibly so you can find things easily. Not always easy in a field
descended from Sun's Java conventions.

What field is descended from Sun's Java conventions?
I was frankly disappointed to see that from all the available naming
styles (UpperAndLower, lowerAndUpper, ALLCAPS,
lower_with_underscores, ...) JavaScripters do almost nothing to use
these in an intelligent way. We should have conventions, as Java does,
that let you see immediately that you are looking at an object
reference, public method, etc.

There are no private methods, so we don't need method names that start
with underscores.
For what it's worth, 6 conventions say JavaScript, one says
Javascript. None use anything else.

JavaScript refers to a specific implementation, but is often used to
refer to all ECMAScript (like Coke is sometimes used to describe all
cola.)
 
G

Greg Murray

I asked Google for "javascript code conventions". He pointed me to
seven convention documents. (More exactly, to Crockford and six lesser
convention documents.) I have compiled all the conventions in a single
document, here:

http://www.martinrinehart.com/articles/javascript-conventions.html

I stress that these are NOT my conventions; this is a compilation of
the others. My job: clerk. I tried to be a good clerk, organizing
sensibly so you can find things easily. Not always easy in a field
descended from Sun's Java conventions.

I was frankly disappointed to see that from all the available naming
styles (UpperAndLower, lowerAndUpper, ALLCAPS,
lower_with_underscores, ...) JavaScripters do almost nothing to use
these in an intelligent way. We should have conventions, as Java does,
that let you see immediately that you are looking at an object
reference, public method, etc.

For what it's worth, 6 conventions say JavaScript, one says
Javascript. None use anything else.

I'd like this thread to stick to the document (fixes, documents I
should include, ...) If you want to argue for or against particular
issues, please focus on the issue in a separate post. I'll set things
off in my next post.

Nice to see everything in one place. I fixed some of the links in the
document
I wrote so many years ago. I'll try to give it some more love given I
have more
to share 3 years later.

-Greg
 
M

Martin Rinehart

David said:
What field is descended from Sun's Java conventions?

The JavaScript convention document field.

Crockford credits Sun's Java conventions explicitly. Two of the
"following" six credit Crockford explicitly.
 
M

Martin Rinehart

Greg said:
Nice to see everything in one place. I fixed some of the links in the
document
I wrote so many years ago. I'll try to give it some more love given I
have more
to share 3 years later.

Welcome, Greg Murray.

3 years later and you're still Google top 10. Congrats.

Are you still odd man out re indenting function blocks?

Martin
 
M

Martin Rinehart

Greg said:
I fixed some of the links

I see that includes the Dojo link. Wow! That's a serious, major
conventions document. Lotta meat on those bones. I'll add it soon as I
get a chance. Many thanks.

Martin
 
T

Thomas 'PointedEars' Lahn

Martin said:
The JavaScript convention document field.
Pardon?

Crockford credits Sun's Java conventions explicitly. Two of the
"following" six credit Crockford explicitly.

You are not making any sense. I suggest you stop falling for
self-proclaimed gurus (even Crockford can be wrong) and start thinking for
yourself. Then it will become easier for you to formulate understandable
statements.

BTW, since when is Google a "he"?


PointedEars
 
M

Martin Rinehart

Thomas said:
You are not making any sense. I suggest you stop falling for
self-proclaimed gurus (even Crockford can be wrong)

Maybe that was too fast. Crockford and another JavaScript convention
directly credit Sun's Java conventions document as their starting
point. Two other JS conventions credit Crockford's conventions
document as being their starting point. The Sun document is poorly
organized (or not really organized at all). That was a gentle jab at
Crockford's lack of visible organization.
BTW, since when is Google a "he"?

My poetic license is current, paid through year end.

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,225
Latest member
Top Crypto Podcasts

Latest Threads

Top