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.
  • 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
                      • 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

                        B Offline
                        B Offline
                        Brad Jennings
                        wrote on last edited by
                        #41

                        Joel Holdsworth wrote: i don't understand how anyone could mistaxe if(whatever) for a function call especially as the if turns a blue colour! Well, it turns blue in Visual Studio but not necessarily if you are doing C programming on a system running Solaris.:) Brad Jennings Sonork: 100.36360 AIM: hongg99

                        1 Reply Last reply
                        0
                        • O OmegaSupreme

                          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 Offline
                          N Offline
                          Navin
                          wrote on last edited by
                          #42

                          Once you've started doing "B", you'll never look back, and wonder why you ever coded with "A" at all. :cool: "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

                          O L J 3 Replies 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

                            B Offline
                            B Offline
                            Brad Jennings
                            wrote on last edited by
                            #43

                            I used A for about the first 4 months (it's what our teacher taught us) and then I had a programming partner that really hated A so I was converted to B. I use B even if the conditional statement is a one-liner:

                            if(true)
                            {
                                DoSomething();
                            }
                            

                            Also, as far as indentation goes, I used to use tabs everywhere but the TA for one of my classes last year broke me of that and now I use 4 spaces. Brad Jennings Sonork: 100.36360 AIM: hongg99

                            1 Reply Last reply
                            0
                            • N Nitron

                              I see a lot of old-school c-coders using A X| ~Nitron.


                              ññòòïðïðB A
                              start

                              T Offline
                              T Offline
                              Troy Marchand
                              wrote on last edited by
                              #44

                              Well, one reason for this (and I used to do it) was due to screen size .... ever program with CGA graphics (320x200 pixels, 40x25 in text). So ya, for those of us who have been doing it long enough to still remember writing DOS TSRs had to write C++ code this way. Troy

                              D 1 Reply Last reply
                              0
                              • N Navin

                                Once you've started doing "B", you'll never look back, and wonder why you ever coded with "A" at all. :cool: "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

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

                                I've seen the light, I'm going to give it a try :-D


                                The smaller the mind the greater the conceit. Aesop

                                1 Reply Last reply
                                0
                                • T Troy Marchand

                                  Well, one reason for this (and I used to do it) was due to screen size .... ever program with CGA graphics (320x200 pixels, 40x25 in text). So ya, for those of us who have been doing it long enough to still remember writing DOS TSRs had to write C++ code this way. Troy

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

                                  Yes, I remember writing them with monochrome screens, but they were 80x25 in size.


                                  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

                                    Y Offline
                                    Y Offline
                                    Yusuf
                                    wrote on last edited by
                                    #47

                                    B: I wonder why no body mentioned one clear advantage of A in the old times? what is wrong with this code? if(true){; DoSomething(); DoSomethingElse(); }

                                    J 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
                                      Christian Graus
                                      wrote on last edited by
                                      #48

                                      I use B, always have, always will ( well, not really, I believe having a standard is more important than it's details, I would follow any standard my employer set ). But I'm curious about a few things 1. With two simple choices, why was this not a 'vote 5 for, vote 1 for' poll, and 2. Why is it that every post on this thread that I look at has been voted for twice and has a score of 3 ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                                      N N 2 Replies 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

                                        L Offline
                                        L Offline
                                        Luca Leonardo Scorcia
                                        wrote on last edited by
                                        #49

                                        Well... since nobody does, I dare to say I use and prefer A. I find it MUCH more readable, uses less screen space (we all know what a screen-eater is VS), and I save an Enter at each indent. When I need to underline the bracket of course B is the way to go, but often simple indentation is enough. Oh, and one last thing: for function definitions A is my preferred way. Example:

                                        void DailyPrayer(int times)
                                        {
                                        for (int i = 0; i < times; ++i) {
                                        printf("I love CP\r\n");
                                        printf("And you?\r\n");
                                        }

                                        for (int i = 0; i < times; ++i)
                                            printf("http://www.codeproject.com");
                                        

                                        }

                                        Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)

                                        J R 2 Replies Last reply
                                        0
                                        • C Christian Graus

                                          I use B, always have, always will ( well, not really, I believe having a standard is more important than it's details, I would follow any standard my employer set ). But I'm curious about a few things 1. With two simple choices, why was this not a 'vote 5 for, vote 1 for' poll, and 2. Why is it that every post on this thread that I look at has been voted for twice and has a score of 3 ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

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

                                          Christian Graus wrote: 2. Why is it that every post on this thread that I look at has been voted for twice and has a score of 3 ? See a post I made a little while ago, some spineless coward voted all the posts in favor of "B" a 1. So I went and voted them a 5, just so they weren't all at 1. "I'd be up a piece if I hadn't swallowed my bishop." Mr. Ed, playing chess

                                          C 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