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 Offline
    D Offline
    Dan Neely
    wrote on last edited by
    #1

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

    P OriginalGriffO Sander RosselS J L 18 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

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      What do you mean? Isn't that K&R?

      This space intentionally left blank.

      OriginalGriffO D 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

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

        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 – ∞)

        "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

        E B 2 Replies Last reply
        0
        • P PIEBALDconsult

          What do you mean? Isn't that K&R?

          This space intentionally left blank.

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

          It's a mix of K&R and 1TBS X|

          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 – ∞)

          "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
          • P PIEBALDconsult

            What do you mean? Isn't that K&R?

            This space intentionally left blank.

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

            I thought K&R put the function declaration on the previous line too.

            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

              Sander RosselS Offline
              Sander RosselS Offline
              Sander Rossel
              wrote on last edited by
              #6

              Code VB instead! *Hides* :D

              It's an OO world.

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

              D K 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(); }
                }

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

                Well VB at least has the advantage of not being able to run on a crackdingleberry.

                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
                • OriginalGriffO OriginalGriff

                  It's a mix of K&R and 1TBS X|

                  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 – ∞)

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  I only see K&R. Maybe you need to show a bigger sample.

                  This space intentionally left blank.

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