Io sono pieno di fisse
Se prendo il readme di FidoCadJ c'è tutto questo, più altre istruzioni:
-indent properly, using 4 spaces
-no tabulation character allowed in sources
-no trailing spaces
-blocks delimited by curly braces are indented as follows:
- Codice: Seleziona tutto
for(i=0; i<10; ++i) { // Curly brace here
// indented code (4 spaces)
System.out.println("I counted up to "+i);
} // close brace here at the same level of the 'for'
-methods are indented as follows:
- Codice: Seleziona tutto
void dummy(int i, int j)
{ // put the starting brace here
System.out.println("Indent code");
} // put the closing brace here
-classes and interfaces are indented as follows:
- Codice: Seleziona tutto
class Dummy
{ // Curly brace here.
// the rest of the class.
}
-switches are indented as follows:
- Codice: Seleziona tutto
int dummy(int i)
{
int j;
switch(i) {
case 1:
j=3;
break;
case 2:
j=2;
break;
default:
j=0
}
return j;
}
-if an if condition spans over multiple lines, put the brace on the following line
-the class names always start with a capital letter
-variables never start with a capital letter
-methods never start with a capital letter
-no lines longer than 80 characters
-Unix-style for newlines is mandatory
-employing _ in names of types or variables is deprecated
Si parla di Java, ma ho abitudini praticamente identiche anche con il C ed il C++.
Tra l'altro, poco importa lo stile, è questione di gusti personali (tutti sono d'accordo che è importante indentare, poi ci si scanna sui dettagli). Però è indispensabile che lo stile rimanga uniforme in un progetto, soprattutto se ci sono tante persone che ci lavorano sopra. Per Java sono diventato un grande fan di Checkstyle, ma se non mi ricordo male non ho mai trovato nulla di simile per il C/C++.