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 Offline
    L Offline
    lotuspro
    wrote on last edited by
    #1

    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!

    R H J M D 21 Replies 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!

      R Offline
      R Offline
      retZ
      wrote on last edited by
      #2

      I use Notation 2 but I see a lot of Unix folks using Notation 1 There are no failures.. only extended learning opportunities.

      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!

        H Offline
        H Offline
        Henry miller
        wrote on last edited by
        #3

        Seems to be a unix vs windows thing. Overall it is style, and it doesn't matter so much WHICH you do so long as everyone is doing the same thing! If you already have a style tell the new guys "deal with it", and make them conform. If you don't, either the project lead decides, or you vote. Either way someone has to deal with a style they don't like. You can complain that you hate it (I hate a lot of the style I'm forced to follow), and you can even find proof that some other side is better. (if such a thing is possible) In the end though you follow the rules and force everyone else to. Only rarly is changing the rules allowed

        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
          Jerry Hammond
          wrote on last edited by
          #4

          I use 2. I have noticed that a lot of folks who cut their teeth on Java are prone to use notation 1 while those who cut their teeth on C or C++ use 2. Best, Jerry

          The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark

          Toasty0.com

          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
            Michael P Butler
            wrote on last edited by
            #5

            It's an old religous war but... lotuspro wrote: private void foo() { //statements } Always the above. Certainly reads better. I've used the style for near on all 15 years. The only time I don't use it, is if I have to fit in with a company coding-standard... but nearly every company I've worked for uses the second style, or has adopted it. :-D Michael CP Blog [^]

            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!

              D Offline
              D Offline
              David Stone
              wrote on last edited by
              #6

              I always do the latter. Seems more readable and all.


              Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?

              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
                Maximilien
                wrote on last edited by
                #7

                I hate, really hate the first version ... I usually re-align all code with { on the same line as function names or conditions ( if, while, ... ) anyway ... this is a religion topic ...


                Maximilien Lincourt Your Head A Splode - Strong Bad

                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
                  Chris Maunder
                  wrote on last edited by
                  #8

                  lotuspro wrote: perhaps we should have a poll on CodeProject Like this[^]? cheers, Chris Maunder

                  L M J 3 Replies Last reply
                  0
                  • C Chris Maunder

                    lotuspro wrote: perhaps we should have a poll on CodeProject Like this[^]? cheers, Chris Maunder

                    L Offline
                    L Offline
                    lotuspro
                    wrote on last edited by
                    #9

                    yes... just like that one :) appreciate the comments y'all.

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      lotuspro wrote: perhaps we should have a poll on CodeProject Like this[^]? cheers, Chris Maunder

                      M Offline
                      M Offline
                      Michael P Butler
                      wrote on last edited by
                      #10

                      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 1 Reply Last reply
                      0
                      • C Chris Maunder

                        lotuspro wrote: perhaps we should have a poll on CodeProject Like this[^]? cheers, Chris Maunder

                        J Offline
                        J Offline
                        Jerry Hammond
                        wrote on last edited by
                        #11

                        Oh gee, go ahead, spoil another fine debate about braces, brackets, and indentation. }~ ;););) Best, Jerry

                        The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark

                        Toasty0.com

                        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!

                          S Offline
                          S Offline
                          Steve Maier
                          wrote on last edited by
                          #12

                          I know that a few publishers (magazine and book) want format #1 when you submit code snippets for an article or for the book. This helps cut down space used by the article and space in a magazine means $$$$. I use format #2 myself, but like it was mentioned before, the coding standards of the company that you are doing work for are what should be followed. Alot of companies that I have seen don't list this in their standards because of the style wars over this type of thing. I had a technician working for me years ago that used to take printouts and then get a ruler and draw red lines to connect the braces to make it easier for him to see. Of course this means that format #1 would be alot harder for him to figure out. Steve Maier, MCSD MCAD

                          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
                            Lost User
                            wrote on last edited by
                            #13

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