Is there a best coding style for indentations (same line, next line)?
- by Luis Soeiro
I prefer Pascal-like coding style, where the beginning and ending of a code block are on the same column. I think that it is easier to read and to handle cut and paste than the other kind of coding style.
The style I prefer (Pascal-like):
void fooBar(String s)
{
int a;
int length=s.length();
for (int i=0;i<length;i++)
{
if (i>10)
{
System.out.println(i);
System.out.println(s.charAt(i));
}
}
}
The style that was adopted by the Java community:
void fooBar(String s) {
int a;
int length=s.length();
for (int i=0;i<length;i++){
if (i>10){
System.out.println(i);
System.out.println(s.charAt(i));
}
}
}
So why do you use one type or the other (please cite an objective reason)?