What is the name of this convention for curly braces?

前端 未结 7 1520
借酒劲吻你
借酒劲吻你 2021-02-19 13:58

I\'m a bit puzzled by the number of developers I see writing methods and classes with curly braces below the class name or the method. What convention are they following?

<
相关标签:
7条回答
  • 2021-02-19 14:22

    I prefer the second convention because the closing bracket will be directly below the opening one, so it's easier to find.

    0 讨论(0)
  • 2021-02-19 14:23

    The first convention saves precious space. The bracket matching is done by the editor anyway.

    0 讨论(0)
  • 2021-02-19 14:36

    The second convention is also the default indentation style of Visual Studio (and therefore rather common) for C#

    0 讨论(0)
  • 2021-02-19 14:37

    This is a standard style convention called the ANSI style. It's common in other languages besides Java, as well.

    0 讨论(0)
  • 2021-02-19 14:37

    The latter looks like the Allman indent style which is quite popular in C++ but I haven't seen it used often in Java.

    0 讨论(0)
  • 2021-02-19 14:39

    See: http://en.wikipedia.org/wiki/Indent_style

    Syrion has identified it as the ANSI style, Sun follows the K&R style of brace placement.

    Tangent: and now I know that accursed style is called Whitesmiths style

    0 讨论(0)
提交回复
热议问题