da
DarwinNE » 17 dic 2011, 19:33
angus ha scritto:Per quanto mi riguarda utilizzo questo sistema di indentazione:
Utilizzo, in C, C++ e Java, esattamente lo stesso modo di indentare descritto da
angus. L'unica eccezione è che quando inizio una funzione metto la graffa subito a capo.
Ecco un pezzo del codice di FidoCadJ:
- Codice: Seleziona tutto
/** Draw the handles of all selected primitives
@param G the graphic context to be used.
*/
public void drawSelectedHandles(Graphics2D G, MapCoordinates cs)
{
int i;
for (i=0; i<primitiveVector.size(); ++i){
if(((GraphicPrimitive)primitiveVector.get(i)).getSelected())
((GraphicPrimitive)primitiveVector.get(i)).drawHandles(G,
cs);
}
}
Semmai la cosa dovesse invogliare qualcuno, ecco un pezzo del README associato ai sorgenti di FidoCadJ, in cui ho specificato lo stile da adottare:
- Codice: Seleziona tutto
3.4 Coding conventions
----------------------
The following coding conventions have been applied for the FidoCadJ source
code:
- tab set to 4 spaces
- blocks delimited by curly braces are indented as follows:
for(i=0; i<10; ++i) { // starting brace here
// indented code (4 spaces)
System.out.println("I counted up to "+i);
} // close brace here at the same level of the 'if'
- methods are indented as follows:
void dummy (int i, int j)
{ // put the starting brace here
System.out.println("Indent code");
} // put the closing brace here
- the class names always start with a capital letter, and so does methods
- variables never start with a capital letter
- an instance of the class does have its first letter in lower case
- each public class and method should be documented with Javadoc syntax
- no lines longer than 80 characters
- commits should not break the build