What Style Do You Code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kier
    Former Lead Developer, vBulletin
    • Sep 2000
    • 8179

    #31
    All vBulletin 3 code follows this standard:
    PHP Code:
    if ($condition == 'moo')
    {
        
    // cow
    }
    else if (
    $condition == 'baa')
    {
        
    // sheep
    }
    else
    {
        
    // alien

    ie: Newline before all braces, braces inline with loop initialisation code, with contents indented by a single tab. 'else if' rather than 'elseif'. All operators separated by spaces ($condition == 'baa' / $x = 1; $str = 'baa' . $var . 'moo'; etc.)

    Comment

    • Kier
      Former Lead Developer, vBulletin
      • Sep 2000
      • 8179

      #32
      At some point in the future I will publish the vBulletin 3 Code Standards Document to which the devs have adhered during this project.

      Comment

      • CeleronXT
        Senior Member
        • Mar 2002
        • 3217

        #33
        Originally posted by Kier
        All vBulletin 3 code follows this standard:
        PHP Code:
        if ($condition == 'moo')
        {
        // cow
        }
        else if (
        $condition == 'baa')
        {
        // sheep
        }
        else
        {
        // alien

        ie: Newline before all braces, braces inline with loop initialisation code, with contents indented by a single tab. 'else if' rather than 'elseif'. All operators separated by spaces ($condition == 'baa' / $x = 1; $str = 'baa' . $var . 'moo'; etc.)
        Awww, pewp.
        "63,000 bugs in the code, 63,000 bugs, you get 1 whacked with a service pack, now there's 63,005 bugs in the code."
        "Before you critisize someone, walk a mile in their shoes. That way, when you critisize them, you're a mile away and you have their shoes."
        Utopia Software - Current Software: Utopia News Pro (news management system)

        Comment

        • fury
          Senior Member
          • Jun 2001
          • 1464

          #34
          I usually go for Style 1, it is the style I learned to do in mIRC (my first experience with any kind of interpreting language)

          I am going to try to lean towards style 2 in the future though, if only for the fact that it makes it easier for people who don't have bracket matching like in TextPad to look through the code.

          Originally posted by CeleronXT
          Just curious what style everyone here codes in.. I myself am style 1.

          Style 1:
          PHP Code:
          if (condition) {
             
          // do something here
          } elseif (condition) {
             
          // do something else
          } else {
             
          // do something else

          Style 2:
          PHP Code:
          if (condition)
            {
             
          // do something here
            
          }
          elseif (
          condition)
            {
             
          // do something else
            
          }
          else
            {
             
          // something else
            

          Style 3:
          PHP Code:
          if (condition) {
             
          // do something here
          }
          elseif (
          condition) {
             
          // do something else
          }
          else {
             
          // final action

          Comment

          • rebby
            Senior Member
            • Mar 2001
            • 220
            • 2.3.3

            #35
            Originally posted by NTLDR
            I use Style 1, I find Style 2 extreamly hard to read for some reason.
            ditto.

            Comment

            • Radgam
              Member
              • Jan 2003
              • 84

              #36
              Originally posted by NTLDR
              I use Style 1, I find Style 2 extreamly hard to read for some reason.
              Same here.

              i've always used Style 1 (although i indent content between { n' } ) when coding as it was generally what was used in perl books so i'm most used to that style. I think it looks neat, and tidy but for long amounts of coding it's sometimes too crampt so i'll spread it out a bit:
              PHP Code:
              if (condition) {

              /* do something here
              lots of
              coding here
              */


              For PHP i sometimes move more towards Style3 because i don't like the way homesite displays PHP coding but it's also just because i'm a php n00b

              Comment

              • GameCrash
                Senior Member
                • Oct 2000
                • 422
                • 3.6.x

                #37
                When programming PHP, I use Style 1 as I really like compact code...

                When programming C#, I use something like Style 2 (this is the standard formatting setting in Visual Studio .NET and I got accustomed to it before I found the switch to change this
                GameCrash

                Project Tools Importer for forum threads
                Current Version: 1.0.0 Beta 3

                Comment

                • RixiuS
                  Senior Member
                  • Jul 2003
                  • 114
                  • 3.0.0 Beta 7

                  #38
                  Style 2, and Style 3 sometimes.

                  Comment

                  • i am coo man
                    Senior Member
                    • Jun 2002
                    • 237

                    #39
                    Style 1, because its soo goshdarn sexy!

                    I like it cause its compact and looks cool. But I can't deny that style 2 (without indended braces and code) is easier to read.

                    BTW!! Why the heck would anyone use else if instead of elseif ???

                    Comment

                    • Jerry
                      Senior Member
                      • Dec 2002
                      • 9137
                      • 1.1.x

                      #40
                      Originally posted by i am coo man
                      BTW!! Why the heck would anyone use else if instead of elseif ???
                      readability, convention, personal preference.
                      I wrote ImpEx.

                      Blog | Me

                      Comment

                      • Cagez
                        Senior Member
                        • Dec 2002
                        • 1449

                        #41
                        I use style 2 without those crazy spaces there. I find it easier to note the different code blocks if the braces are on the new line, while in style 1 I struggle to find where things start/end.

                        Comment

                        • Alcar
                          Member
                          • Aug 2002
                          • 58
                          • 3.6.x

                          #42
                          Style 5.

                          Alcar...
                          http://www.oddworldforums.net

                          Comment

                          • poolking
                            Senior Member
                            • Aug 2002
                            • 2061

                            #43
                            I'm still learning php, so I don't really know what style I code in.

                            Comment

                            • Dean C
                              Senior Member
                              • Mar 2002
                              • 4571
                              • 3.5.x

                              #44
                              I code like Kier - can't go wrong there
                              Dean Clatworthy - Web Developer/Designer

                              Comment

                              • Cyborg from DH
                                Senior Member
                                • Nov 2002
                                • 305

                                #45
                                I code with my style:

                                http://www.deluxeportal.com/specs/coding_standards.php

                                Comment

                                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                                Working...