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

Code style

Scheduled Pinned Locked Moved The Lounge
questioncss
39 Posts 27 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.
  • L lotuspro

    i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

    C Offline
    C Offline
    Colin Angus Mackay
    wrote on last edited by
    #14

    The first version is only used by one person where I work. I've used the latter version for as long as I have used a language with curly braces (I started coding in C++ 12 years ago) and have never used anything else.


    "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!

    C 1 Reply Last reply
    0
    • M Michael P Butler

      Chris Maunder wrote: Like this[^]? So do you keep all the poll links in your head or did you have to look it up? Michael CP Blog [^]

      C Offline
      C Offline
      Chris Maunder
      wrote on last edited by
      #15

      You didn't realise that there isn't actually a SQL backend, it's actually me hand-typing all responses to page requests? That's why page view times can be a little long if I'm tired, and why forums can get unthreaded if it's a Friday night and I've been on the turps. Hey - it seemed cheaper than trying to pay for SQL licences... cheers, Chris Maunder

      J 1 Reply Last reply
      0
      • L lotuspro

        i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #16

        private:
        void foo()
        {
        //statements
        }

        Company standard. Felt strange at first, but I got used to it, and now I use it everywhere


        My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

        J C C J P 5 Replies Last reply
        0
        • C Colin Angus Mackay

          The first version is only used by one person where I work. I've used the latter version for as long as I have used a language with curly braces (I started coding in C++ 12 years ago) and have never used anything else.


          "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!

          C Offline
          C Offline
          Carlos H Perez
          wrote on last edited by
          #17

          I used the first style for 7 years in C++. I have been using the second style for almost 3 years in C#. With both styles I have and will continue making money. If someone pays me to do it one way or another, I will do it the way he wants it as long as he pays me my rate. Is not that what matters? The same goes for languages. I can write in Java, Visual Basic, C++, or C#. If you pay me, you choose the language and coding standards. Regards, Carlos H. Perez.

          1 Reply Last reply
          0
          • L lotuspro

            i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

            J Offline
            J Offline
            J Dunlap
            wrote on last edited by
            #18

            :)

            "A people that values its privileges above its principles soon loses both."
            -- Dwight D. Eisenhower

            1 Reply Last reply
            0
            • L lotuspro

              i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

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

              Are you trying to start a flame war in the lounge? ;) [edit]I agree with you :)[/edit] -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

              P 1 Reply Last reply
              0
              • N Nemanja Trifunovic

                private:
                void foo()
                {
                //statements
                }

                Company standard. Felt strange at first, but I got used to it, and now I use it everywhere


                My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

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

                Ick! Don't you get dizzy with the curly's aligned with the statements? It reminds me of the style a teacher of mine used:

                if(x) {
                // statements
                }

                (He did it that way because he didn't have an autoindenting editor, and he was lazy. He never admitted it, but I know his character. And yeah, he hacked code when I was still breast feeding. :rolleyes:) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                N 1 Reply Last reply
                0
                • C Chris Maunder

                  You didn't realise that there isn't actually a SQL backend, it's actually me hand-typing all responses to page requests? That's why page view times can be a little long if I'm tired, and why forums can get unthreaded if it's a Friday night and I've been on the turps. Hey - it seemed cheaper than trying to pay for SQL licences... cheers, Chris Maunder

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

                  Working 9 to 5 would be holiday for you, wouldn't it? ;) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                  1 Reply Last reply
                  0
                  • L lotuspro

                    i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

                    P Offline
                    P Offline
                    peterchen
                    wrote on last edited by
                    #22

                    lotuspro wrote: waste of a linebreak If coding style was about saving line breaks you would have a point. There is no standard, though the latter is seen far more frequent than the former, at least for functions and structs. House rules: If an inline function fits on one line, it can go on one line. Otherwise, classes, functions, structs always as version 2. if, for etc. is up to the coder.


                    we are here to help each other get through this thing, whatever it is Vonnegut jr.
                    sighist || Agile Programming | doxygen

                    1 Reply Last reply
                    0
                    • L Lost User

                      Yes it takes a bit more space but I prefer the second style. PS Indentation ? private void foo() { [tab here] //statements } ;P The tigress is here :-D

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

                      #2! ~Nitron.


                      ññòòïðïðB A
                      start

                      1 Reply Last reply
                      0
                      • J Jorgen Sigvardsson

                        Ick! Don't you get dizzy with the curly's aligned with the statements? It reminds me of the style a teacher of mine used:

                        if(x) {
                        // statements
                        }

                        (He did it that way because he didn't have an autoindenting editor, and he was lazy. He never admitted it, but I know his character. And yeah, he hacked code when I was still breast feeding. :rolleyes:) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                        N Offline
                        N Offline
                        Nemanja Trifunovic
                        wrote on last edited by
                        #24

                        Frankly, I don't care. It is a matter of habit, anyway. Noone can convince me one style has any particular advantages over another.


                        My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                        1 Reply Last reply
                        0
                        • N Nemanja Trifunovic

                          private:
                          void foo()
                          {
                          //statements
                          }

                          Company standard. Felt strange at first, but I got used to it, and now I use it everywhere


                          My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                          C Offline
                          C Offline
                          Chris Losinger
                          wrote on last edited by
                          #25

                          that's our standard, too. but i refuse to use it, as i think it's fundamentally wrong. Software | Cleek

                          1 Reply Last reply
                          0
                          • J Jorgen Sigvardsson

                            Are you trying to start a flame war in the lounge? ;) [edit]I agree with you :)[/edit] -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                            P Offline
                            P Offline
                            peterchen
                            wrote on last edited by
                            #26

                            *must* *resist* *to* *flame* *Jörgen*


                            we are here to help each other get through this thing, whatever it is Vonnegut jr.
                            sighist || Agile Programming | doxygen

                            J 1 Reply Last reply
                            0
                            • L lotuspro

                              i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

                              M Offline
                              M Offline
                              Matt Newman
                              wrote on last edited by
                              #27

                              I had a programming class that was co-taught (2 hours per lecture, 1 professor per hour) and one used numero 1 and one used the second. Very annoying! Matt Newman
                              What is your malfunction? - Dangeresque, too?

                              1 Reply Last reply
                              0
                              • L lotuspro

                                i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

                                L Offline
                                L Offline
                                Luis Alonso Ramos
                                wrote on last edited by
                                #28

                                I've always, in the 12 or so years I've used C/C++/C#, used the braces on a line of its own, unindented. -- LuisR ___________   Luis Alonso Ramos   Chihuahua, Mexico   www.luisalonsoramos.com

                                1 Reply Last reply
                                0
                                • N Nemanja Trifunovic

                                  private:
                                  void foo()
                                  {
                                  //statements
                                  }

                                  Company standard. Felt strange at first, but I got used to it, and now I use it everywhere


                                  My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                  C Offline
                                  C Offline
                                  caractacus
                                  wrote on last edited by
                                  #29

                                  Sorry, but this is anal. X|

                                  1 Reply Last reply
                                  0
                                  • L lotuspro

                                    i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

                                    C Offline
                                    C Offline
                                    caractacus
                                    wrote on last edited by
                                    #30

                                    In my mind, both are valid!:omg:

                                    void foo() {
                                    if (!false) {
                                    burp();
                                    }
                                    }

                                    or

                                    void foo(
                                    int param1, // doc param 1
                                    int param2, // doc param 2
                                    int param3
                                    )
                                    {
                                    burp();
                                    }

                                    Why? I do not like CLOSING parentheses or braces lost on the end of broken/multi lines. Opening braces should be placed at the most logical point. You see, too many blanks/dim lines are just as detrimental as cramming.

                                    1 Reply Last reply
                                    0
                                    • N Nemanja Trifunovic

                                      private:
                                      void foo()
                                      {
                                      //statements
                                      }

                                      Company standard. Felt strange at first, but I got used to it, and now I use it everywhere


                                      My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                      J Offline
                                      J Offline
                                      Jim A Johnson
                                      wrote on last edited by
                                      #31

                                      Eeeuw. Anyone who finds this to be clear simply has difficulty thinking straight.

                                      1 Reply Last reply
                                      0
                                      • P peterchen

                                        *must* *resist* *to* *flame* *Jörgen*


                                        we are here to help each other get through this thing, whatever it is Vonnegut jr.
                                        sighist || Agile Programming | doxygen

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

                                        Bring it on! I've got skin made of asbest. ;) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                                        P 1 Reply Last reply
                                        0
                                        • L lotuspro

                                          i've been chatting with the new guy at work today and he respectfully informs me he can't recall the last time he saw this notation: private void foo() { //statements } and contends that almost always people use: private void foo() { //statements } which to me is a total waste of a linebreak and less readable. worse still, the other new dude concurs? whassup with that? being a fan of the former notation, it seems to me that either the new generation of coders are being being taught different, or the old ones are getting too anal about space. my question is... what in fact is the standard? perhaps we should have a poll on CodeProject and settle this once and for all!

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

                                          Version 2 is of course the only correct version. :) And I've worked in a lot of enterprise environments where I've never seen anything but v2 there.

                                          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