Thursday, February 16th, 2006

JavaScript Style Guide

Category: Dojo, JavaScript

Ah the hours of arguing over coding style. We have all been there.

It starts with:

Should our team/company have guidelines?

And then it gets to:

{ braces MUST be on the same line, are you NUTS!!!

It is often good to look at what others are doing, and the Dojo Toolkit has their
Javascript Programming Conventions Guide published.

It is very detailed, going over naming conventions, file conventions, variable usage, code layout, whitespace, and comments.

Dojo JavaScript Style Guide

Posted by Dion Almaer at 9:13 am

3.7 rating from 65 votes


Comments feed TrackBack URI

[…] have reported on Dojo Toolkit’s new JavaScript style guide. Ah the hours of arguing over coding style. We have all been there. […]

Pingback by Ajax Lessons » JavaScript Style Guide — February 16, 2006

Guidelines are very important and overall Dojo’s are very good. We just need to convince Alex to allow us to put an extra space after a function definition. :P

function something() {
function something(){ //(makes my head hurt)

Comment by Dan — February 16, 2006

I think the very first sentence of the guide takes care of that. :-)

Any violation to this guide is allowed if it enhances readability.

Comment by Michael Geary — February 16, 2006

Dan, I won’t fight you too hard in your modules ;-)

Comment by Alex Russell — February 16, 2006

I would like to extend this suggestion to have a space in front of all opening braces: “if (..) {“, “while(..) {“, etc. Otherwise, very nice guide!

Comment by Pocho — February 17, 2006

Only someone who is utterly inexperienced at working with others code would even consider suggesting putting the { on the same line. { and } must line up – this is a huge help in finding missing block structure.

I say this from 30 years of experience of programming in languages that use { } and from having tried all the styles.

Comment by xman — February 17, 2006

[…] JavaScript Style Guide […]

Pingback by Ajaxian » Audible Ajax 16: March State of Ajax — March 14, 2006

[…] Javascript Style […]

Pingback by Web Development » Project Organization — March 17, 2006

I agree with xman { should not be on same line. They should be below and line up
so it
is easy
to follow

Comment by zuna loon — May 8, 2006

Looks like they’ve moved it here sometime in the last 2 years:

Comment by dprevite — March 25, 2008

Leave a comment

You must be logged in to post a comment.