Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBacterius

Posted 16 April 2013 - 07:19 AM

What about using the best of both worlds?
 

int  doSomething(int x)
{     int y;
      // ... do complex operation
      return y;
}

      

This can be tedious to format if you don't have smart tabbing functionality (though I agree this is a weak argument). But it just looks so wroooooooooooong...

Personally I've always used the first style because it is much more consistent to me, and clearly delimits scopes. Sure, it might take up a few more lines of code, but the curly braces are neatly on the same indentation level, rather than having one of the curly braces placed at the end of an arbitrarily long statement.

I also like the Python way - do away with curly braces altogether - though it brings its own set of issues (is this a tab or a space?)

This is kind of a subjective opinion, though, and it's best to go with what is already being used in the codebase since having two or more different coding styles competing with each other can be very frustrating. Though if you are starting a new project, you should definitely use the first style the style you and your team prefer.


#2Bacterius

Posted 16 April 2013 - 07:18 AM

What about using the best of both worlds?
 

int  doSomething(int x)
{     int y;
      // ... do complex operation
      return y;
}

      

This can be tedious to format if you don't have smart tabbing functionality (though I agree this is a weak argument). But it just looks so wroooooooooooong...

Personally I've always used the first style because it is much more consistent to me, and clearly delimits scopes. Sure, it might take up a few more lines of code, but the curly braces are neatly on the same indentation level, rather than having one of the curly braces placed at the end of an arbitrarily long statement.

I also like the Python way - do away with curly braces altogether - though it brings its own set of issues (is this a tab or a space?)

This is kind of a subjective opinion, though, and it's best to go with what is already being used in the codebase since having two or more different coding styles competing with each other can be very frustrating. Though if you are starting a new project, you should definitely use the first style the style you prefer.


#1Bacterius

Posted 16 April 2013 - 07:14 AM

What about using the best of both worlds?

int  doSomething(int x)
{     int y;
      // ... do complex operation
      return y;
}

      


This can be tedious to format if you don't have smart tabbing functionality (though I agree this is a weak argument). But it just looks so wroooooooooooong...

Personally I've always used the first style because it is much more consistent to me, and clearly delimits scopes. Sure, it might take up a few more lines of code, but the curly braces are neatly on the same indentation level, rather than having one of the curly braces placed at the end of an arbitrarily long statement.

I also like the Python way - do away with curly braces altogether - though it brings its own set of issues (is this a tab or a space?)

PARTNERS