What Style Do You Code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chen
    Senior Member
    • Jun 2001
    • 8388

    #16
    Originally posted by CeleronXT
    You mean "else if" really works? !! I never knew that.. :O
    Some languages (such as JavaScript) require you to use "else if" and not "elseif".

    If you replace the space with a newline it makes a lot of sense:
    PHP Code:
    if ($foo) {
        
    bar();
    } else
        if (
    $bar) {
            
    foo();
        } 
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

    Comment

    • Valkyre
      Senior Member
      • Jun 2001
      • 619

      #17
      Style 2.
      Need a job done? Get in contact with me and we'll see what we can work out.

      Comment

      • Bane
        Senior Member
        • Jul 2000
        • 515

        #18
        Style 2 without the funny indents

        Comment

        • Floris
          Senior Member
          • Dec 2001
          • 37767

          #19
          When I first write something, I try to comment everything, so I understand what I make and easier to read back and fix things and find syntax errors.

          Which would be close to style 2, with indents, just to get easier tree following.

          But once it works, I try to clean up as much as possible, and try to be as compact as possible, and just comment on functions, and sometimes on the closing tags for if statements, to make sure I am working on the right one.

          Most times, my code doesn't work

          Comment

          • Beorn
            Senior Member
            • May 2002
            • 451

            #20
            Originally posted by Chen
            The new standard for vBulletin is style 2 without the spaces in front of brackets.
            Darn....lots of extra lines.....
            Perhaps you guys should try phpCodeBeautifier. It makes it much prettier.

            Comment

            • Cyborg from DH
              Senior Member
              • Nov 2002
              • 305

              #21
              I see no reason why

              PHP Code:
              if ($condition==true)
              {
              }
              else
              {

              is any worse than

              PHP Code:
              if ($condition==true) {
              } else {

              they both contain the same number of bits, and the first one looks better, IMO.

              Comment

              • Lost_in_Dark
                New Member
                • Nov 2002
                • 2

                #22
                This is my style:
                PHP Code:
                if (condition)

                    
                // do something here 
                }
                elseif (
                condition)

                    
                // do something else 
                }
                else

                    
                // do something else 

                Comment

                • Chen
                  Senior Member
                  • Jun 2001
                  • 8388

                  #23
                  Personally I don't like that because it makes everything longer. Unfortunately, my mouse wheel does not move X bytes every time, it jumps lines.
                  Chen Avinadav
                  Better to remain silent and be thought a fool than to speak out and remove all doubt.

                  גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

                  Comment

                  • Icheb
                    Senior Member
                    • Nov 2002
                    • 1291

                    #24
                    Cyborg from DH: It's neither worse nor better, it's just a matter of personal preference.

                    Comment

                    • NTLDR
                      Senior Member
                      • Apr 2002
                      • 212
                      • 3.0.0 Gamma

                      #25
                      I use Style 1, I find Style 2 extreamly hard to read for some reason.
                      vBulletin.org Moderator
                      The Sisters Three Charmed Discussion Forums

                      Comment

                      • Cyborg from DH
                        Senior Member
                        • Nov 2002
                        • 305

                        #26
                        Originally posted by Icheb
                        Cyborg from DH: It's neither worse nor better, it's just a matter of personal preference.
                        I know it's just a matter of personal preference. I just hear people sometimes saying one is better, when they are both just as good. It is up to you to decide which one looks best to you.

                        Comment

                        • CeleronXT
                          Senior Member
                          • Mar 2002
                          • 3217

                          #27
                          Originally posted by NTLDR
                          I use Style 1, I find Style 2 extreamly hard to read for some reason.
                          Me too. I can understand it when { is at the end of a line, but when it starts having { and } on separate lines, it gets too confusing..
                          "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

                          • La La Lol
                            Member
                            • Apr 2003
                            • 54

                            #28
                            Originally Posted by CeleronXT
                            You mean "else if" really works? !! I never knew that.. :O
                            I didn't know that "elseif" works.. does it?
                            Last edited by La La Lol; Tue 29 Apr '03, 12:55am.

                            Comment

                            • NTLDR
                              Senior Member
                              • Apr 2002
                              • 212
                              • 3.0.0 Gamma

                              #29
                              Originally posted by La La Lol
                              I didn't know that "elseif" works.. does it?
                              It does indeed, I tend to use elseif as opposed to else if.
                              vBulletin.org Moderator
                              The Sisters Three Charmed Discussion Forums

                              Comment

                              • Sn2
                                Senior Member
                                • Feb 2002
                                • 295
                                • 3.5.x

                                #30
                                Originally posted by Lost_in_Dark
                                This is my style:
                                PHP Code:
                                if (condition)

                                    
                                // do something here 
                                }
                                elseif (
                                condition)

                                    
                                // do something else 
                                }
                                else

                                    
                                // do something else 

                                Same as what I use

                                Comment

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