What are the reasons for the various shapes of braces?

I read the Zend Framework coding standards , where they indicate that curly braces after class definitions should be on the next line, "one true curly brace form."

class MyClass
{
    function....
}

I usually have brackets on one line:

class OtherClass {
    function ...
}

What is the reason for placing brackets on the next line? Or use any other style, for that matter?

+5
source share
9 answers

Personal preference is really a real "reason."

+7
source

. .

, .

+8

, , , . .

+7

:

  • ( )
  • ( - )

: , . , , .

+3

, ( , ).

Allman Style, . , , , .

:

+3

. . PHP, , , #, .

+1

...

, "" ( , ... ), , , , .
, ..

+1

, . , "" , "" .

, , , . , , .

.

0

It doesn't matter what style you use? No. Does it matter that everyone working on the same project or source file uses the same brace style? No; not only does it not matter, but it is useful if the styles of the brackets differ from one encoder to another, even in the same file.

"Why is this particular piece of code doing this?"

"I don't know, it's in Kevin's handwriting, let him ask him."

0
source

All Articles