What is the name of this convention for curly braces?

前端 未结 7 1559
借酒劲吻你
借酒劲吻你 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:44

    As you say, you've seen it quite a lot - doesn't that make it a convention in its own right, whether or not there's a single source or name for that convention? It's so easy to describe, I don't think it needs a particular attribution. Wikipedia's "indent style" page calls it the Allman Style or ANSI style, but frankly I've been using it for years without ever hearing that name, and I don't think knowing the name is going to change anything about the way I code :)

    Unlike conventions such as the naming of public types and methods, brace location has no impact on developers using the compiled version of your code... so it's okay (IMO) for different projects and companies to have different takes on this... likewise whether to use spaces or tabs, the number of spaces to use for indentation etc. I suspect that's why you've seen more variation on bracing (and probably private variables) than on other aspects of convention.

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