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. Coding standards: curly bracket style

Coding standards: curly bracket style

Scheduled Pinned Locked Moved The Lounge
com
38 Posts 26 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.
  • OriginalGriffO OriginalGriff

    There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

    Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

    S Offline
    S Offline
    Slacker007
    wrote on last edited by
    #2

    ...weepy widdle Richard :laugh:

    OriginalGriffO R 2 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

      T Offline
      T Offline
      Tim Carmichael
      wrote on last edited by
      #3

      If a standard is a standard, it should be enforced as such, otherwise, it is just a suggestion. That being said, each organization needs to determine what they consider to be a standard. At one of my previous employs, the 'standard' was to have the file name match the routine name, and since the overarching standard was 9 character file names, we ended up with routine names like: SRVEXTPSM and SRVEXTSSM. When I objected because I had no idea what the routine was supposed to do, I was told it was following the naming standard as though that was an explanation in itself.

      F R 2 Replies Last reply
      0
      • S Slacker007

        ...weepy widdle Richard :laugh:

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #4

        "so many security holes, the Adobe Flash team has been called in to make it more secure" got me.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #5

          That story arc gets quite interesting... :laugh:

          veni bibi saltavi

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

            M Offline
            M Offline
            MarkTJohnson
            wrote on last edited by
            #6

            I wouldn't convict him, might even help hold her down.

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

              C Offline
              C Offline
              charlieg
              wrote on last edited by
              #7

              Here we go.... :) On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - *to me*. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that. But the curlies? jumping into fox hole now.

              Charlie Gilley Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

              F N OriginalGriffO P V 9 Replies Last reply
              0
              • T Tim Carmichael

                If a standard is a standard, it should be enforced as such, otherwise, it is just a suggestion. That being said, each organization needs to determine what they consider to be a standard. At one of my previous employs, the 'standard' was to have the file name match the routine name, and since the overarching standard was 9 character file names, we ended up with routine names like: SRVEXTPSM and SRVEXTSSM. When I objected because I had no idea what the routine was supposed to do, I was told it was following the naming standard as though that was an explanation in itself.

                F Offline
                F Offline
                Foothill
                wrote on last edited by
                #8

                Then you should hid on of these in there: EATSHTNDY or URSTNDSKS

                if (Object.DividedByZero == true) { Universe.Implode(); } Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016

                1 Reply Last reply
                0
                • C charlieg

                  Here we go.... :) On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - *to me*. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that. But the curlies? jumping into fox hole now.

                  Charlie Gilley Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                  F Offline
                  F Offline
                  Foothill
                  wrote on last edited by
                  #9

                  I would have to agree. When you are looking at code you have never seen before, anything that makes it easier to understand what the code is doing is helpful. Separating out sections of code visually does help conceptualize program flow and structure.

                  if (Object.DividedByZero == true) { Universe.Implode(); } Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016

                  1 Reply Last reply
                  0
                  • C charlieg

                    Here we go.... :) On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - *to me*. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that. But the curlies? jumping into fox hole now.

                    Charlie Gilley Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                    N Offline
                    N Offline
                    Nish Nishant
                    wrote on last edited by
                    #10

                    I am like you, love style #1, just can't stand style #2.

                    Regards, Nish


                    Website: www.voidnish.com Blog: voidnish.wordpress.com

                    1 Reply Last reply
                    0
                    • C charlieg

                      Here we go.... :) On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - *to me*. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that. But the curlies? jumping into fox hole now.

                      Charlie Gilley Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #11

                      Yeah - I hate reading 1TB because it does it's damnedest to hide the open bracket. I'm not fond of Allman either - I use Whitesmiths as it just feels more "together" to indent the brackets to the same level as the code block it's enclosing:

                      if (a == b)
                      {
                      c();
                      }

                      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      P J 2 Replies Last reply
                      0
                      • C charlieg

                        Here we go.... :) On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - *to me*. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that. But the curlies? jumping into fox hole now.

                        Charlie Gilley Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                        P Offline
                        P Offline
                        PauloJuanShirt
                        wrote on last edited by
                        #12

                        camELCase?

                        1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          Yeah - I hate reading 1TB because it does it's damnedest to hide the open bracket. I'm not fond of Allman either - I use Whitesmiths as it just feels more "together" to indent the brackets to the same level as the code block it's enclosing:

                          if (a == b)
                          {
                          c();
                          }

                          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                          P Offline
                          P Offline
                          PeejayAdams
                          wrote on last edited by
                          #13

                          ``` if (a == b) { c(); } ``` UGH! I really don't like that one at all. I used to do things K&R style: ```cs if (a == b) { c(); } ``` but then I realised that that's a little bit ghastly, too. So for a long time I've been doing it this way ... ``` if (a == b) { c(); } ``` ... and getting a little bit miffed with anyone that doesn't. It really makes code flow much more visible.

                          OriginalGriffO 1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

                            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                            D Offline
                            D Offline
                            den2k88
                            wrote on last edited by
                            #14

                            For me K&R. CamelCase when public members, camelCase when private.

                            GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                            1 Reply Last reply
                            0
                            • P PeejayAdams

                              ``` if (a == b) { c(); } ``` UGH! I really don't like that one at all. I used to do things K&R style: ```cs if (a == b) { c(); } ``` but then I realised that that's a little bit ghastly, too. So for a long time I've been doing it this way ... ``` if (a == b) { c(); } ``` ... and getting a little bit miffed with anyone that doesn't. It really makes code flow much more visible.

                              OriginalGriffO Offline
                              OriginalGriffO Offline
                              OriginalGriff
                              wrote on last edited by
                              #15

                              I like it because it's consistent - it's treating the indentation of the compound statement and the single statement in the same way. But it's horses for courses! :laugh:

                              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                              P 1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                I like it because it's consistent - it's treating the indentation of the compound statement and the single statement in the same way. But it's horses for courses! :laugh:

                                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                                P Offline
                                P Offline
                                PeejayAdams
                                wrote on last edited by
                                #16

                                I can see the logic behind it and I've worked with a couple of people that have used it but I find it murder on the eyeballs. Needless to say, if that was the one that I used, I'd probably say the same about my way (i.e. the proper way :) ).

                                1 Reply Last reply
                                0
                                • C charlieg

                                  Here we go.... :) On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - *to me*. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that. But the curlies? jumping into fox hole now.

                                  Charlie Gilley Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                                  V Offline
                                  V Offline
                                  Vark111
                                  wrote on last edited by
                                  #17

                                  I'm weird. for me it depends on the language, because I let my style be dictated by the larger community choice. I suppose that means I'm either indecisive, or I don't really care one way or the other. C/C++/C# - Style 1, and I can't abide code written in style 2. Javascript - Style 2. To the point that if I see javascript written in Style 1, I don't even recognize it as valid javascript. Java? By the time I've reached my first curly, I've already written too much Java, so I just delete the project and start over in a better language. :-\

                                  D J 2 Replies Last reply
                                  0
                                  • T Tim Carmichael

                                    If a standard is a standard, it should be enforced as such, otherwise, it is just a suggestion. That being said, each organization needs to determine what they consider to be a standard. At one of my previous employs, the 'standard' was to have the file name match the routine name, and since the overarching standard was 9 character file names, we ended up with routine names like: SRVEXTPSM and SRVEXTSSM. When I objected because I had no idea what the routine was supposed to do, I was told it was following the naming standard as though that was an explanation in itself.

                                    R Offline
                                    R Offline
                                    realJSOP
                                    wrote on last edited by
                                    #18

                                    In the absence of an established corporate coding standard, when editing an existing file, you should always adapt the style already used in the file. When creating a new file, you are free to go your own way, but consideration should be given to maintaining the same style as the other files in the folder (if there is a dominant style). When I'm at home, I use the first style. At work, I'm lucky enough to working on my own stuff, so my preferred style is in force there as well.

                                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                    -----
                                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                    -----
                                    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                    P K 2 Replies Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      There Are 10 Types Of Programmers[^] Mediation[^] Made me laugh! :laugh:

                                      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                                      N Offline
                                      N Offline
                                      NandaKumer
                                      wrote on last edited by
                                      #19

                                      BEFORE - for C# style and NOW - Java.

                                      1 Reply Last reply
                                      0
                                      • R realJSOP

                                        In the absence of an established corporate coding standard, when editing an existing file, you should always adapt the style already used in the file. When creating a new file, you are free to go your own way, but consideration should be given to maintaining the same style as the other files in the folder (if there is a dominant style). When I'm at home, I use the first style. At work, I'm lucky enough to working on my own stuff, so my preferred style is in force there as well.

                                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                        -----
                                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                        -----
                                        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                        P Offline
                                        P Offline
                                        PeejayAdams
                                        wrote on last edited by
                                        #20

                                        John Simmons / outlaw programmer wrote:

                                        In the absence of an established corporate coding standard, when editing an existing file, you should always adapt the style already used in the file.

                                        Generally speaking, yes, and I'd never consider reformatting someone's code because they use a different style but I must confess that when I come across a really badly formatted SQL script - all random indents and inconsistent capitilisation combined with rubbish aliases and so forth - I just can't stop myself from tidying it up. It's a little ironic in that I can't remember when I last tidied my desk (or my house for that matter) but messy code annoys the living daylights out of me.

                                        R 1 Reply Last reply
                                        0
                                        • V Vark111

                                          I'm weird. for me it depends on the language, because I let my style be dictated by the larger community choice. I suppose that means I'm either indecisive, or I don't really care one way or the other. C/C++/C# - Style 1, and I can't abide code written in style 2. Javascript - Style 2. To the point that if I see javascript written in Style 1, I don't even recognize it as valid javascript. Java? By the time I've reached my first curly, I've already written too much Java, so I just delete the project and start over in a better language. :-\

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

                                          Interesting, since I don't recognize javascript as a valid language. (My "favorite" part about Python: scratching your head why something is failing only to realize that one line is indented using spaces and the next tabs.)

                                          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