[Dojo-interest] Code conventions

Torkel Holm contact at torkel.no
Tue Apr 4 15:38:56 MDT 2006


Alex Russell wrote:
> On Wednesday 22 March 2006 3:26 am, Torkel Holm wrote:
> 
>> Is the style guide[1] deprecated?
>> I do a lot of diving through the source and it doesn't seems
>> that everyone agrees about it ;)
> 
> Feel free to point to places that don't conform. We'd like to fix them.

It's primarly about the layout section.

I can probably pick a random file and find all permutations of different
statement layouts etc. where different coders have contributed ;)

I don't think a need to give a rationale for this.

Lets take the for-statement

(1)
// compact
for(initialization;condition;increment){

(2)
// space before the opening brace
for(initialization;condition;increment) {

(2)
// space after semicolon
for(initialization; condition; increment){

(3)
// space after reserved word and before brace
for (initialization; condition; increment) {

Why not strictly follow the "de facto" Java (I know we are talking about 
  Javascript ;) ) code conventions promoted by Sun which are used by 
both Mozilla and Microsoft for Javascript code?

example:

for(var i=0;i<a.length;i++){
     doSomething();
}
// vs
for (var i = 0; i < a.length; i++) {
     doSomething();
}

I prefer to used the rhino compressor and gzip :)


BTW the code in the Yahoo! UI Library doesn't looks too much better.

-- 
Torkel Holm



More information about the Dojo-interest mailing list