Is there a best coding style for indentations (same line, next line)?

Posted by Luis Soeiro on Stack Overflow See other posts from Stack Overflow or by Luis Soeiro
Published on 2008-10-01T19:42:46Z Indexed on 2010/04/25 11:33 UTC
Read the original article Hit count: 229

Filed under:
|

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)?

© Stack Overflow or respective owner

Related posts about subjective

Related posts about coding-style