Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the reasoning behind the different brace forms? [closed]

I'm reading through the Zend Framework coding standards, where they state that curly brace after a Class definitions should be on the next line, the "one true brace form".

class MyClass
{
    function....
}

I usually have the braces on the same line:

class OtherClass {
    function ...
}

What's the reason for putting the brace on the next line? Or using any other style, for that matter?

like image 376
Jrgns Avatar asked Oct 30 '08 06:10

Jrgns


2 Answers

Having the braces on lines by themselves helps to visually separate the inner part from the outer part. That makes it easier to quickly scan through source code and distinguish blocks from their surroundings.

Plus, having the braces at the same indentation level makes it easier for the eye to find a match.

like image 162
HS. Avatar answered Sep 24 '22 20:09

HS.


Personal preference is really the only real "reason".

like image 30
Levi Rosol Avatar answered Sep 23 '22 20:09

Levi Rosol