The "programming rules" document gives the rules about the indentation to use and some synthesis examples. Here is a longer list of case-by-case examples, using the Javascript syntax. The bad/good "if" examples are also bad/good examples for any other kind of block: "while", "for", "function", "<td>", etc.
| BAD | GOOD |
|---|---|
prErr ("..."); | prErr("..."); |
function someFct() | function someFct () |
a = 1; | a= 1; |
if(a==1) ... | if (a==1) ... |
if (a = b) ... | if ((a= b)) ... |
if (!(a)) ... | if (!a) ... |
if (a) { a= b; } | if (a) a= b; |
if (a){a=b; b=2;} | if (a) { a= b; b= 2; } |
if (a) {
a= b; ...
}
| if (a)
{ a= b; ...
}
|
if (a)
{
a= b; ...
}
| if (a)
{ a= b; ...
}
|
if (a)
{
a= b; ...
}
| if (a)
{ a= b; ...
}
|
if (a)
{a= b;
c= d;
}
| if (a)
{ a= b;
c= d;
}
|
if (a)
{ a= b; ...
}
| if (a)
{ a= b; ...
}
|
if (a)
{ a= b;
if (b) ...
}
| if (a)
{ a= b;
if (b) ...
}
|
if (a)
{ a= b;
}
| if (a)
{ a= b;
}
|
function someFct1 ()//...
{ ...
}
function someFct2 () //...
{ ...
}
| function someFct1 () //...
{ ...
}
function someFct2 () //...
{ ...
}
|
Les deux présentations suivantes d'une même fonction
illustrent l'intérêt d'indenter. Néanmoins, la version
de gauche a encore 7 types de problèmes de forme – dont 4 types
de problèmes d'indentation/espacement – cités dans votre
checklist. Citez tous ces types de problèmes par ordre d'apparition
dans l'exemple de gauche (→ lorsque vous en citez un, donnez la ligne de
sa 1ère occurence).