1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Braces Placement

Discussion in 'XenForo Development Discussions' started by ragtek, Sep 11, 2011.

  1. ragtek

    ragtek Guest

    I know, Kier & Mike prefers

    class Foo
        public function 
    BUT, if you place the braces at the end of the line, the IDE will show the complete 1. line with the brace at the end and not only {
    So, if it's placed in the same line as the class name, method head, "command"??(don't know any other word:D ), you'll see it, if it's in the next line, the IDE will only show the {

    bad.PNG vs better.PNG
  2. Syndol

    Syndol Guest

    The way it is being done now is much easier to read.
  3. Kier

    Kier XenForo Developer Staff Member

    I'm afraid that's an artefact of your IDE being retarded. Eclipse displays the function prototype correctly.
    Reeve of Shinra likes this.
  4. Cezz

    Cezz Well-Known Member

    That is specific to the IDE you use it seems as I have never experienced this myself!
  5. Floris

    Floris Guest

    I always have preferred

    if (this) {
    do this
    } else {
    do that

    For some reason I used to read through that easier, and it was clear which } belonged to what ..

    But the last 2 years I have moved away from this and made it a bit of a coding standard to use

    if (this)
    do this

    Either way, it still doen't matter. But the longer your code becomes, the easier it is to make mistakes if the { } are on the lines of stuff you're handling. Doing it the second way, I made less mistakes with that.
    Cezz likes this.
  6. Cezz

    Cezz Well-Known Member

    I agree Floris, the first method is easier to read with small code, but the second method is a lot easier when your code gets larger, especially when used with correct tabbing also!
  7. ragtek

    ragtek Guest

    OK, it is a bug in my IDE :D

Share This Page