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. The only thing worse than code written using The Wrong Brace Style(tm)

The only thing worse than code written using The Wrong Brace Style(tm)

Scheduled Pinned Locked Moved The Lounge
wpfcomquestion
55 Posts 30 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.
  • D Dan Neely

    ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

    PhotoBomberApp::PhotoBomberApp()
    {
    // Create a QMLDocument and load it, using build patterns
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");

    qml->setContextProperty("\_photoBomber", this);
    
    if (!qml->hasErrors()) {
        // The application Page is created from QML.
        Page \*appPage = qml->createRootObject<Page>();
    
        if (appPage) {
    
            // Set the application scene.
            Application::instance()->setScene(appPage);
        }
    }
    

    }

    Some opening braces on their own line; others on the preceding line. **SPEW**[^]

    Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

    J Offline
    J Offline
    JMK89
    wrote on last edited by
    #9

    ...I don't see a problem here! Does that make me a bad person?

    Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"

    D J 2 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      Reformat the whole lot to Whitesmiths style! Then you can breathe easy... :laugh:

      Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

      E Offline
      E Offline
      Espen Harlinn
      wrote on last edited by
      #10

      OriginalGriff wrote:

      Reformat the whole lot to Whitesmiths style!

      I came to C/C++ from turbo pascal - so naturally I did C/C++ in the Whitesmiths style ... I still guess that the primary reason for

      void foo() {
      }

      was the 12" monitors of yesteryears ... On the other hand, I guess the best reason for having a coding style-guide is to avoid wasting time discussing coding styles.

      Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra

      M J 2 Replies Last reply
      0
      • Sander RosselS Sander Rossel

        Code VB instead! *Hides* :D

        It's an OO world.

        public class Sander : Lazy<Person>{
        public void DoWork(){ throw new NotImplementedException(); }
        }

        K Offline
        K Offline
        Keith Barrow
        wrote on last edited by
        #11

        Giving up coding seems a bit of an overreaction...

        PB 369,783 wrote:

        I just find him very unlikeable, and I think the way he looks like a prettier version of his Mum is very disturbing.[^]

        1 Reply Last reply
        0
        • D Dan Neely

          ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

          PhotoBomberApp::PhotoBomberApp()
          {
          // Create a QMLDocument and load it, using build patterns
          QmlDocument *qml = QmlDocument::create("asset:///main.qml");

          qml->setContextProperty("\_photoBomber", this);
          
          if (!qml->hasErrors()) {
              // The application Page is created from QML.
              Page \*appPage = qml->createRootObject<Page>();
          
              if (appPage) {
          
                  // Set the application scene.
                  Application::instance()->setScene(appPage);
              }
          }
          

          }

          Some opening braces on their own line; others on the preceding line. **SPEW**[^]

          Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #12

          Invest in a code reformatting tool & rest easy. Of course, if there's multiple devs involved, then you also need to invest the time in applying a standard formatting prior to check in (to avoid the 'every line has been changed' problems of source code comparison.

          MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

          1 Reply Last reply
          0
          • J JMK89

            ...I don't see a problem here! Does that make me a bad person?

            Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"

            D Offline
            D Offline
            Dan Neely
            wrote on last edited by
            #13

            That's an implicit endorsement of a brace style I dislike, so yes it does. :doh:

            Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

            J 1 Reply Last reply
            0
            • D Dan Neely

              That's an implicit endorsement of a brace style I dislike, so yes it does. :doh:

              Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

              J Offline
              J Offline
              JMK89
              wrote on last edited by
              #14

              Well which one don't you like?

              Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"

              Richard Andrew x64R 1 Reply Last reply
              0
              • J JMK89

                Well which one don't you like?

                Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"

                Richard Andrew x64R Offline
                Richard Andrew x64R Offline
                Richard Andrew x64
                wrote on last edited by
                #15

                The wrong one, of course.

                The difficult we do right away... ...the impossible takes slightly longer.

                D 1 Reply Last reply
                0
                • D Dan Neely

                  ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

                  PhotoBomberApp::PhotoBomberApp()
                  {
                  // Create a QMLDocument and load it, using build patterns
                  QmlDocument *qml = QmlDocument::create("asset:///main.qml");

                  qml->setContextProperty("\_photoBomber", this);
                  
                  if (!qml->hasErrors()) {
                      // The application Page is created from QML.
                      Page \*appPage = qml->createRootObject<Page>();
                  
                      if (appPage) {
                  
                          // Set the application scene.
                          Application::instance()->setScene(appPage);
                      }
                  }
                  

                  }

                  Some opening braces on their own line; others on the preceding line. **SPEW**[^]

                  Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #16

                  ctrl+e+d reformats according to your VS settings.

                  Never underestimate the power of human stupidity RAH

                  D 1 Reply Last reply
                  0
                  • M Mycroft Holmes

                    ctrl+e+d reformats according to your VS settings.

                    Never underestimate the power of human stupidity RAH

                    D Offline
                    D Offline
                    Dan Neely
                    wrote on last edited by
                    #17
                    1. Unfortunately VS doesn't support targeting CackBerry 1) I have to use a rimmed version of Eclipse FILE_NOT_FOUND: No posting constructive replies to an obvious venting session

                    Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                    M 1 Reply Last reply
                    0
                    • Richard Andrew x64R Richard Andrew x64

                      The wrong one, of course.

                      The difficult we do right away... ...the impossible takes slightly longer.

                      D Offline
                      D Offline
                      Dan Neely
                      wrote on last edited by
                      #18

                      Exactly.

                      Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                      1 Reply Last reply
                      0
                      • D Dan Neely

                        ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

                        PhotoBomberApp::PhotoBomberApp()
                        {
                        // Create a QMLDocument and load it, using build patterns
                        QmlDocument *qml = QmlDocument::create("asset:///main.qml");

                        qml->setContextProperty("\_photoBomber", this);
                        
                        if (!qml->hasErrors()) {
                            // The application Page is created from QML.
                            Page \*appPage = qml->createRootObject<Page>();
                        
                            if (appPage) {
                        
                                // Set the application scene.
                                Application::instance()->setScene(appPage);
                            }
                        }
                        

                        }

                        Some opening braces on their own line; others on the preceding line. **SPEW**[^]

                        Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                        J Offline
                        J Offline
                        JimmyRopes
                        wrote on last edited by
                        #19

                        Dan Neely wrote:

                        Some opening braces on their own line; others on the preceding line.

                        The real question is does the code function properly? :rolleyes:

                        The report of my death was an exaggeration - Mark Twain
                        Simply Elegant Designs JimmyRopes Designs
                        Think inside the box! ProActive Secure Systems
                        I'm on-line therefore I am. JimmyRopes

                        D 1 Reply Last reply
                        0
                        • D Dan Neely
                          1. Unfortunately VS doesn't support targeting CackBerry 1) I have to use a rimmed version of Eclipse FILE_NOT_FOUND: No posting constructive replies to an obvious venting session

                          Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                          M Offline
                          M Offline
                          Mycroft Holmes
                          wrote on last edited by
                          #20

                          Dan Neely wrote:

                          FILE_NOT_FOUND: No posting constructive replies to an obvious venting session

                          Yeah, sorry, nasty habit pissing on a good rant :-O

                          Never underestimate the power of human stupidity RAH

                          1 Reply Last reply
                          0
                          • J JimmyRopes

                            Dan Neely wrote:

                            Some opening braces on their own line; others on the preceding line.

                            The real question is does the code function properly? :rolleyes:

                            The report of my death was an exaggeration - Mark Twain
                            Simply Elegant Designs JimmyRopes Designs
                            Think inside the box! ProActive Secure Systems
                            I'm on-line therefore I am. JimmyRopes

                            D Offline
                            D Offline
                            Dan Neely
                            wrote on last edited by
                            #21

                            JimmyRopes wrote:

                            The real question is does the code function properly? :rolleyes:

                            Which part of...

                            Quote:

                            For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform

                            ... id you not understand?

                            Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                            J 1 Reply Last reply
                            0
                            • E Espen Harlinn

                              OriginalGriff wrote:

                              Reformat the whole lot to Whitesmiths style!

                              I came to C/C++ from turbo pascal - so naturally I did C/C++ in the Whitesmiths style ... I still guess that the primary reason for

                              void foo() {
                              }

                              was the 12" monitors of yesteryears ... On the other hand, I guess the best reason for having a coding style-guide is to avoid wasting time discussing coding styles.

                              Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra

                              M Offline
                              M Offline
                              MRJIT
                              wrote on last edited by
                              #22

                              Whitesmith's rules! I never seize to amaze over the triviality of this eternal style format discussion. Who is to say one style is better or worse than another? Is it not more important that the code is A. readable, B. intuitive, C. Bug Free! What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart. This entire theme of discussion is in my years of writing code simply for small talk on coffee breaks and not really adding functionality in my personal opinion.

                              J S U 3 Replies Last reply
                              0
                              • D Dan Neely

                                ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

                                PhotoBomberApp::PhotoBomberApp()
                                {
                                // Create a QMLDocument and load it, using build patterns
                                QmlDocument *qml = QmlDocument::create("asset:///main.qml");

                                qml->setContextProperty("\_photoBomber", this);
                                
                                if (!qml->hasErrors()) {
                                    // The application Page is created from QML.
                                    Page \*appPage = qml->createRootObject<Page>();
                                
                                    if (appPage) {
                                
                                        // Set the application scene.
                                        Application::instance()->setScene(appPage);
                                    }
                                }
                                

                                }

                                Some opening braces on their own line; others on the preceding line. **SPEW**[^]

                                Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                                R Offline
                                R Offline
                                Rage
                                wrote on last edited by
                                #23

                                This is our standard "Spot the Asperger" test in interviews.

                                ~RaGE();

                                I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Do not feed the troll ! - Common proverb

                                1 Reply Last reply
                                0
                                • J JMK89

                                  ...I don't see a problem here! Does that make me a bad person?

                                  Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"

                                  J Offline
                                  J Offline
                                  Joan M
                                  wrote on last edited by
                                  #24

                                  You were already bad, don't try to fool us...

                                  [www.tamautomation.com] | Robots, CNC and PLC machines for grinding and polishing. [YouTube channel]

                                  1 Reply Last reply
                                  0
                                  • D Dan Neely

                                    JimmyRopes wrote:

                                    The real question is does the code function properly? :rolleyes:

                                    Which part of...

                                    Quote:

                                    For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform

                                    ... id you not understand?

                                    Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                                    J Offline
                                    J Offline
                                    JimmyRopes
                                    wrote on last edited by
                                    #25

                                    Dan Neely wrote:

                                    Which part of...For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform...id you not understand?

                                    I id understand you were porting it to a BB10 platform which makes it important that the code functions properly or you will be porting code that does not meet the functionality of the application. Which part of...

                                    JimmyRopes wrote:

                                    The real question is does the code function properly? :rolleyes:

                                    ... id you not understand? :doh:

                                    The report of my death was an exaggeration - Mark Twain
                                    Simply Elegant Designs JimmyRopes Designs
                                    Think inside the box! ProActive Secure Systems
                                    I'm on-line therefore I am. JimmyRopes

                                    1 Reply Last reply
                                    0
                                    • D Dan Neely

                                      ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

                                      PhotoBomberApp::PhotoBomberApp()
                                      {
                                      // Create a QMLDocument and load it, using build patterns
                                      QmlDocument *qml = QmlDocument::create("asset:///main.qml");

                                      qml->setContextProperty("\_photoBomber", this);
                                      
                                      if (!qml->hasErrors()) {
                                          // The application Page is created from QML.
                                          Page \*appPage = qml->createRootObject<Page>();
                                      
                                          if (appPage) {
                                      
                                              // Set the application scene.
                                              Application::instance()->setScene(appPage);
                                          }
                                      }
                                      

                                      }

                                      Some opening braces on their own line; others on the preceding line. **SPEW**[^]

                                      Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                                      J Offline
                                      J Offline
                                      jaybus56
                                      wrote on last edited by
                                      #26

                                      To me there often is much more to get upset on than brace styles. I can deal with every style (as long as it is the same style in the whole module of course). Meaningless variable names or code with a lot of untreated warnings from the compiler (deserts of trivial to solve warnings hiding the really important one) - that drives me nuts! Brace styles? No, not really...

                                      J 1 Reply Last reply
                                      0
                                      • M MRJIT

                                        Whitesmith's rules! I never seize to amaze over the triviality of this eternal style format discussion. Who is to say one style is better or worse than another? Is it not more important that the code is A. readable, B. intuitive, C. Bug Free! What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart. This entire theme of discussion is in my years of writing code simply for small talk on coffee breaks and not really adding functionality in my personal opinion.

                                        J Offline
                                        J Offline
                                        James Curran
                                        wrote on last edited by
                                        #27

                                        MRJIT wrote:

                                        What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart.

                                        Oddly, what I truly detest in coding style is the code packed so tightly as to be completely inscrutable to any other programmer --- to appear smart.

                                        Truth, James

                                        K S 2 Replies Last reply
                                        0
                                        • D Dan Neely

                                          ... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:

                                          PhotoBomberApp::PhotoBomberApp()
                                          {
                                          // Create a QMLDocument and load it, using build patterns
                                          QmlDocument *qml = QmlDocument::create("asset:///main.qml");

                                          qml->setContextProperty("\_photoBomber", this);
                                          
                                          if (!qml->hasErrors()) {
                                              // The application Page is created from QML.
                                              Page \*appPage = qml->createRootObject<Page>();
                                          
                                              if (appPage) {
                                          
                                                  // Set the application scene.
                                                  Application::instance()->setScene(appPage);
                                              }
                                          }
                                          

                                          }

                                          Some opening braces on their own line; others on the preceding line. **SPEW**[^]

                                          Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                                          D Offline
                                          D Offline
                                          Dominic Amann
                                          wrote on last edited by
                                          #28

                                          This is K&R - other than the if (appPage) not needing braces at all. Nothing wrong here. Move along.

                                          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