Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Style Poll

Style Poll

Scheduled Pinned Locked Moved The Lounge
question
68 Posts 40 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nitron

    How do you guys bracket your code? A:

    if(true){
    DoSomething();
    DoSomethingElse();
    }

    B:

    if(true)
    {
    DoSomething();
    DoSomethingElse();
    }

    C: Other ~Nitron.


    ññòòïðïðB A
    start

    S Offline
    S Offline
    skrtbh
    wrote on last edited by
    #21

    B of course! It's clearly more readable.

    1 Reply Last reply
    0
    • N Nitron

      How do you guys bracket your code? A:

      if(true){
      DoSomething();
      DoSomethingElse();
      }

      B:

      if(true)
      {
      DoSomething();
      DoSomethingElse();
      }

      C: Other ~Nitron.


      ññòòïðïðB A
      start

      A Offline
      A Offline
      Allen Anderson
      wrote on last edited by
      #22

      B. However, there are a couple cases where I stray, such as private string _MyString; public string MyStringProperty { get { return _MyString; } set { _MyString; } } of course, if there is more than 1 line in the get or set I expand it.

      1 Reply Last reply
      0
      • N Nitron

        How do you guys bracket your code? A:

        if(true){
        DoSomething();
        DoSomethingElse();
        }

        B:

        if(true)
        {
        DoSomething();
        DoSomethingElse();
        }

        C: Other ~Nitron.


        ññòòïðïðB A
        start

        T Offline
        T Offline
        Tim Deveaux
        wrote on last edited by
        #23

        Brace yourself - I use mostly A. I use B if:  a. I need readability (eg lots of nested blocks)  b. I'm working with someone else's code, and its B.  c. I hit enter by mistake. Somtimes I use C. So, in brief ?abc : B, (A || C) Or A before B except after abc. See? Simple really. Once you get the 'hang' of it. In any case, those were my indentions.

        V N 2 Replies Last reply
        0
        • J Joel Holdsworth

          B of course - but i don't understand how anyone could mistaxe if(_whatever_) for a function call especially as the if turns a blue colour! Joel Holdsworth

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #24

          Joel Holdsworth wrote: if(whatever) Hmmm, it all looks red to me. ;P Regards, Alvaro


          "I do" is both the shortest and the longest sentence in the English language.

          N 1 Reply Last reply
          0
          • T Tim Deveaux

            Brace yourself - I use mostly A. I use B if:  a. I need readability (eg lots of nested blocks)  b. I'm working with someone else's code, and its B.  c. I hit enter by mistake. Somtimes I use C. So, in brief ?abc : B, (A || C) Or A before B except after abc. See? Simple really. Once you get the 'hang' of it. In any case, those were my indentions.

            V Offline
            V Offline
            Vikram A Punathambekar
            wrote on last edited by
            #25

            Tim Deveaux wrote: I use B if: a. I need readability (eg lots of nested blocks) Code should always be readable. Vikram.


            Shameless plug: http://www.geocities.com/vpunathambekar "And above all, watch with glittering eyes the world around you because the greatest secrets are always hidden in the most unlikely places. Those who don't believe in magic will never find it." - Roald Dahl. Mrs. Schroedinger: "Erwin, what have you been doing to the cat? It looks half-dead!"

            T 1 Reply Last reply
            0
            • N Nitron

              How do you guys bracket your code? A:

              if(true){
              DoSomething();
              DoSomethingElse();
              }

              B:

              if(true)
              {
              DoSomething();
              DoSomethingElse();
              }

              C: Other ~Nitron.


              ññòòïðïðB A
              start

              N Offline
              N Offline
              Navin
              wrote on last edited by
              #26

              Who is the jack--- voting everyone down who says "B" is the best, but won't post a message saying why "A" is better??? I have only seen 1 message in support of A, and it is only partial support. Whoever you are, stop being childish, if you like "A", post a message and say why you like it, just as the rest of us have done! "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

              1 Reply Last reply
              0
              • T Tim Deveaux

                Brace yourself - I use mostly A. I use B if:  a. I need readability (eg lots of nested blocks)  b. I'm working with someone else's code, and its B.  c. I hit enter by mistake. Somtimes I use C. So, in brief ?abc : B, (A || C) Or A before B except after abc. See? Simple really. Once you get the 'hang' of it. In any case, those were my indentions.

                N Offline
                N Offline
                Navin
                wrote on last edited by
                #27

                Tim Deveaux wrote: c. I hit enter by mistake. :-D "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

                1 Reply Last reply
                0
                • N Nitron

                  How do you guys bracket your code? A:

                  if(true){
                  DoSomething();
                  DoSomethingElse();
                  }

                  B:

                  if(true)
                  {
                  DoSomething();
                  DoSomethingElse();
                  }

                  C: Other ~Nitron.


                  ññòòïðïðB A
                  start

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #28

                  I have used style B since day one.


                  A rich person is not the one who has the most, but the one that needs the least.

                  1 Reply Last reply
                  0
                  • N Nitron

                    How do you guys bracket your code? A:

                    if(true){
                    DoSomething();
                    DoSomethingElse();
                    }

                    B:

                    if(true)
                    {
                    DoSomething();
                    DoSomethingElse();
                    }

                    C: Other ~Nitron.


                    ññòòïðïðB A
                    start

                    V Offline
                    V Offline
                    Vikram A Punathambekar
                    wrote on last edited by
                    #29

                    B. I think people who use A should be flogged and committed to an asylum. Or forced to code in VB. :-D Vikram.


                    Shameless plug: http://www.geocities.com/vpunathambekar "And above all, watch with glittering eyes the world around you because the greatest secrets are always hidden in the most unlikely places. Those who don't believe in magic will never find it." - Roald Dahl. Mrs. Schroedinger: "Erwin, what have you been doing to the cat? It looks half-dead!"

                    J 1 Reply Last reply
                    0
                    • M Michael P Butler

                      Nitron wrote: I see a lot of old-school c-coders using A That's because that was the original C style. As featured in The C Programming Language, Second Edition by Brian W. Kernighan and Dennis M. Ritchie. From which we all learnt our first steps into C. (Well, all us old timers anyway) Of course the better programmers did tend to migrate to the more readable 'B' style ;-) Michael But you know when the truth is told, That you can get what you want or you can just get old, Your're going to kick off before you even get halfway through. When will you realise... Vienna waits for you? - "The Stranger," Billy Joel

                      N Offline
                      N Offline
                      Navin
                      wrote on last edited by
                      #30

                      Michael P Butler wrote: That's because that was the original C style. As featured in The C Programming Language, Second Edition by Brian W. Kernighan and Dennis M. Ritchie. Indeed, that's what most supporters of style A say as well. Nothing wrong with that, but I still believe that style was from a time long ago, when screens were only 25 lines long, and a lot of code was printed in books, and space was a premium. Just a guess, though. Michael P Butler wrote: From which we all learnt our first steps into C. (Well, all us old timers anyway) Of course the better programmers did tend to migrate to the more readable 'B' style Yeah, I suppose I learned C/C++ during the "transition" period... and it was quite a religious issue as to what style was better. "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

                      1 Reply Last reply
                      0
                      • A Alvaro Mendez

                        Joel Holdsworth wrote: if(whatever) Hmmm, it all looks red to me. ;P Regards, Alvaro


                        "I do" is both the shortest and the longest sentence in the English language.

                        N Offline
                        N Offline
                        Nitron
                        wrote on last edited by
                        #31

                        Alvaro Mendez wrote: Hmmm, it all looks red to me.

                        if(whatever)

                        :confused: I don't know what you're talking about... ;P ~Nitron.


                        ññòòïðïðB A
                        start

                        1 Reply Last reply
                        0
                        • I Ian Darling

                          Daniel Turini wrote: Actually, B, but with proper identation So is that 2 spaces, 4 spaces, or tabs set to look like 2 or 4 spaces, as opposed to the OPs obviously wrong 3 spaces? :-D


                          Ian Darling "One of the few systems...which has had “no deaths” in the reliability requirements." - Michael Platt

                          N Offline
                          N Offline
                          Navin
                          wrote on last edited by
                          #32

                          I say 4 spaces, even if for no other reason than that is the default in VC6 and VC.NET. :-O The only times I see 3 spaces being used are when there are groups of 2 spacers and 4 spaces of about equal sizes, so they reach a compromise. :-D "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

                          1 Reply Last reply
                          0
                          • N Nitron

                            How do you guys bracket your code? A:

                            if(true){
                            DoSomething();
                            DoSomethingElse();
                            }

                            B:

                            if(true)
                            {
                            DoSomething();
                            DoSomethingElse();
                            }

                            C: Other ~Nitron.


                            ññòòïðïðB A
                            start

                            J Offline
                            J Offline
                            Jon Sagara
                            wrote on last edited by
                            #33

                            Nitron wrote: C: Other

                            if (true)
                            {
                            DoSomething ();
                            DoSomethingElse ();
                            }

                            Jon Sagara Vegetarianism is unhealthy. Humans need protein, and lots of it. Put down those sprouts and pick up a T-bone! -- Michael Moore
                            Latest Article: Breadcrumbs in ASP.NET

                            1 Reply Last reply
                            0
                            • N Nitron

                              How do you guys bracket your code? A:

                              if(true){
                              DoSomething();
                              DoSomethingElse();
                              }

                              B:

                              if(true)
                              {
                              DoSomething();
                              DoSomethingElse();
                              }

                              C: Other ~Nitron.


                              ññòòïðïðB A
                              start

                              C Offline
                              C Offline
                              Callixte
                              wrote on last edited by
                              #34

                              Well, I used to use A when I learned C. Then I coded in Delphi/Pascal, and I was converted to B for obvious reasons. if a=b then begin DoSomething(a); ... end; Since then, I always use B. Callixte.[^]

                              1 Reply Last reply
                              0
                              • N Nitron

                                How do you guys bracket your code? A:

                                if(true){
                                DoSomething();
                                DoSomethingElse();
                                }

                                B:

                                if(true)
                                {
                                DoSomething();
                                DoSomethingElse();
                                }

                                C: Other ~Nitron.


                                ññòòïðïðB A
                                start

                                J Offline
                                J Offline
                                Joe Woodbury
                                wrote on last edited by
                                #35

                                C:

                                     if      (!(!true)))
                                

                                {DoSomething();
                                DoSomethingElse(); }

                                Oops, you meant what I preferred, not what I'm stuck with maintaining right now. Sorry. Then it's B. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                                1 Reply Last reply
                                0
                                • V Vikram A Punathambekar

                                  Tim Deveaux wrote: I use B if: a. I need readability (eg lots of nested blocks) Code should always be readable. Vikram.


                                  Shameless plug: http://www.geocities.com/vpunathambekar "And above all, watch with glittering eyes the world around you because the greatest secrets are always hidden in the most unlikely places. Those who don't believe in magic will never find it." - Roald Dahl. Mrs. Schroedinger: "Erwin, what have you been doing to the cat? It looks half-dead!"

                                  T Offline
                                  T Offline
                                  Tim Deveaux
                                  wrote on last edited by
                                  #36

                                  Vikram Punathambekar wrote: Code should always be readable. Agreed well met etc - but I find A is readable enough for small routines. And routines should be small.

                                  1 Reply Last reply
                                  0
                                  • V Vikram A Punathambekar

                                    B. I think people who use A should be flogged and committed to an asylum. Or forced to code in VB. :-D Vikram.


                                    Shameless plug: http://www.geocities.com/vpunathambekar "And above all, watch with glittering eyes the world around you because the greatest secrets are always hidden in the most unlikely places. Those who don't believe in magic will never find it." - Roald Dahl. Mrs. Schroedinger: "Erwin, what have you been doing to the cat? It looks half-dead!"

                                    J Offline
                                    J Offline
                                    Jorgen Sigvardsson
                                    wrote on last edited by
                                    #37

                                    Vikram Punathambekar wrote: Or forced to code in VB. :growl: I'm suffering a worse fate. Try Powerbuilder. :mad: X| -- Meine Welt ist monoton und minimal, doch ganz total!

                                    1 Reply Last reply
                                    0
                                    • N Nitron

                                      How do you guys bracket your code? A:

                                      if(true){
                                      DoSomething();
                                      DoSomethingElse();
                                      }

                                      B:

                                      if(true)
                                      {
                                      DoSomething();
                                      DoSomethingElse();
                                      }

                                      C: Other ~Nitron.


                                      ññòòïðïðB A
                                      start

                                      J Offline
                                      J Offline
                                      Jorgen Sigvardsson
                                      wrote on last edited by
                                      #38

                                      A of course. Gives me vertical space to separate logical chunks of code, without losing "code density". I only do B for outmost scopes/blocks. -- Meine Welt ist monoton und minimal, doch ganz total!

                                      1 Reply Last reply
                                      0
                                      • N Nitron

                                        How do you guys bracket your code? A:

                                        if(true){
                                        DoSomething();
                                        DoSomethingElse();
                                        }

                                        B:

                                        if(true)
                                        {
                                        DoSomething();
                                        DoSomethingElse();
                                        }

                                        C: Other ~Nitron.


                                        ññòòïðïðB A
                                        start

                                        O Offline
                                        O Offline
                                        OmegaSupreme
                                        wrote on last edited by
                                        #39

                                        A from habit but since theres so many voting B I may change due to peer group pressure or maybe I'll always be a rebel.:confused:


                                        The smaller the mind the greater the conceit. Aesop

                                        N 1 Reply Last reply
                                        0
                                        • J Joel Holdsworth

                                          B of course - but i don't understand how anyone could mistaxe if(_whatever_) for a function call especially as the if turns a blue colour! Joel Holdsworth

                                          R Offline
                                          R Offline
                                          Radoslav Bielik
                                          wrote on last edited by
                                          #40

                                          Joel Holdsworth wrote: but i don't understand how anyone could mistaxe if(whatever) for a function call :) I don't put the space between "if" and the opening bracket as well, I don't like it. ;) rado


                                          Radoslav Bielik http://www.neomyz.com/poll [^] - Get your own web poll

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups