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. Other Discussions
  3. The Back Room
  4. Stupid Programming Standards -- 80 chars?

Stupid Programming Standards -- 80 chars?

Scheduled Pinned Locked Moved The Back Room
visual-studiohelpquestioncareer
21 Posts 13 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.
  • C CurtD

    As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

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

    Well, maybe 80 chars max width is a bit narrow minded, but I understand the reluctance to let programmers go wild. Personally, I hate having to scroll horizontally. Drives me nuts! I tend to cut expressions and statements down into several rows. For instance:

    FunctionCall(parameter1, parameter2, expression1, expression2, expression3, etc...)

    becomes

    FunctionCall(
    parameter1,
    parameter2,
    expression1,
    expression2,
    expression3,
    etc...
    );

    But that's just me. I've seen code whose width was measured in hundreds of chars (I'm exaggerating - a little! ;)). Sad sight indeed.

    -- Kein Mitleid Für Die Mehrheit

    C B 2 Replies Last reply
    0
    • J Jorgen Sigvardsson

      Well, maybe 80 chars max width is a bit narrow minded, but I understand the reluctance to let programmers go wild. Personally, I hate having to scroll horizontally. Drives me nuts! I tend to cut expressions and statements down into several rows. For instance:

      FunctionCall(parameter1, parameter2, expression1, expression2, expression3, etc...)

      becomes

      FunctionCall(
      parameter1,
      parameter2,
      expression1,
      expression2,
      expression3,
      etc...
      );

      But that's just me. I've seen code whose width was measured in hundreds of chars (I'm exaggerating - a little! ;)). Sad sight indeed.

      -- Kein Mitleid Für Die Mehrheit

      C Offline
      C Offline
      CurtD
      wrote on last edited by
      #3

      I should have clarified. I've never seen lines that went for hundreds of chars, but since C++ does not require CRLF's, the goofballs can go crazy. I typically stay within 120 chars. Sometimes 140 if the code is not all that interesting to the flow. And separating params as you suggest is a good idea, but falls under a different standard.

      1 Reply Last reply
      0
      • C CurtD

        As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

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

        My personal pet hate is every function must have one and only one return statement

        C C 2 Replies Last reply
        0
        • J Jorgen Sigvardsson

          Well, maybe 80 chars max width is a bit narrow minded, but I understand the reluctance to let programmers go wild. Personally, I hate having to scroll horizontally. Drives me nuts! I tend to cut expressions and statements down into several rows. For instance:

          FunctionCall(parameter1, parameter2, expression1, expression2, expression3, etc...)

          becomes

          FunctionCall(
          parameter1,
          parameter2,
          expression1,
          expression2,
          expression3,
          etc...
          );

          But that's just me. I've seen code whose width was measured in hundreds of chars (I'm exaggerating - a little! ;)). Sad sight indeed.

          -- Kein Mitleid Für Die Mehrheit

          B Offline
          B Offline
          BoneSoft
          wrote on last edited by
          #5

          I just love those JavaScripter's that like to remove all whitespace as a cheap form of obfuscation.


          Try code model generation tools at BoneSoft.com.

          S 1 Reply Last reply
          0
          • L Lost User

            My personal pet hate is every function must have one and only one return statement

            C Offline
            C Offline
            CurtD
            wrote on last edited by
            #6

            Josh Gray wrote:

            My personal pet hate is every function must have one and only one return statement

            This is so stupid, it is grounds for leaving a company. I suppose they want everything to "goto :End"

            1 Reply Last reply
            0
            • C CurtD

              As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

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

              CurtD wrote:

              we still have the 80 char rule (which I completely ignore).

              Perhaps you could develop a program that will convert your source code into the 80 line junk they want. A comment such as //F&$@*! symbolizes a new line, the program will scan until it finds the 80th char, add that comment and enter a new line. When you want to edit your code, your program can undo it and remove those comments. Its not quite that simple, but you get the idea.

              Word, write letters and sh*t yo.

              1 Reply Last reply
              0
              • C CurtD

                As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

                M Offline
                M Offline
                Mike Gaskey
                wrote on last edited by
                #8

                CurtD wrote:

                Hell, even the mainframe printers from the 1960's would print 120 chars

                aw hell, we could print 132 characters. fyi - the remnants of the 80 position rule still exists in the mainframe world, largely a result of the punch card rule you mention. Mainframe library systems still maintain the 80 position rule but append data to assist the library system maintenance functions.

                Mike The NYT - my leftist brochure. Calling an illegal alien an “undocumented immigrant” is like calling a drug dealer an “unlicensed pharmacist”. God doesn't believe in atheists, therefore they don't exist.

                1 Reply Last reply
                0
                • L Lost User

                  My personal pet hate is every function must have one and only one return statement

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #9

                  See, while I disagree with this as a requirement, 99% of my functions do have only one return statement, it is a good principle to aim for, what's wrong is when it becomes a hard and fast rule and you have to write code around the rule.

                  Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  L 1 Reply Last reply
                  0
                  • C Christian Graus

                    See, while I disagree with this as a requirement, 99% of my functions do have only one return statement, it is a good principle to aim for, what's wrong is when it becomes a hard and fast rule and you have to write code around the rule.

                    Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

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

                    Christian Graus wrote:

                    See, while I disagree with this as a requirement, 99% of my functions do have only one return statement, it is a good principle to aim for, what's wrong is when it becomes a hard and fast rule and you have to write code around the rule.

                    What I really disliked about this rule was code that should look like this void Function(int param) { if(param < 0) return; //lots more code } now becomes void Function(int param) { if(param >= 0) { //lots of code } //nothing here } I found that often the "real work" of the function would be many levels of indentation deep

                    S D 2 Replies Last reply
                    0
                    • C CurtD

                      As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

                      D Offline
                      D Offline
                      DaveX86
                      wrote on last edited by
                      #11

                      CurtD wrote:

                      Hell, even the mainframe printers from the 1960's would print 120 chars

                      132 chars is what I remember for the 'wide format' dot matrix printers. Whatever makes code easier to read and follow is the rule I go by.

                      1 Reply Last reply
                      0
                      • C CurtD

                        As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

                        F Offline
                        F Offline
                        FyreWyrm
                        wrote on last edited by
                        #12

                        You get 80 characters? We only get 72. Seriously, only 72. I think it's so the code can easily be read by the blind (my boss). He has a 20" CRT monitor and uses 800 x 600 resolution so he can easily see what's on the screen.

                        1 Reply Last reply
                        0
                        • B BoneSoft

                          I just love those JavaScripter's that like to remove all whitespace as a cheap form of obfuscation.


                          Try code model generation tools at BoneSoft.com.

                          S Offline
                          S Offline
                          Shog9 0
                          wrote on last edited by
                          #13

                          It's also a cheap form of compression. Hey, bytes matter...

                          1 Reply Last reply
                          0
                          • L Lost User

                            Christian Graus wrote:

                            See, while I disagree with this as a requirement, 99% of my functions do have only one return statement, it is a good principle to aim for, what's wrong is when it becomes a hard and fast rule and you have to write code around the rule.

                            What I really disliked about this rule was code that should look like this void Function(int param) { if(param < 0) return; //lots more code } now becomes void Function(int param) { if(param >= 0) { //lots of code } //nothing here } I found that often the "real work" of the function would be many levels of indentation deep

                            S Offline
                            S Offline
                            Shog9 0
                            wrote on last edited by
                            #14

                            Exactly. It's a good guideline, in that returns deep in the bowels of the code just make it harder to follow... but common sense dictates there is a time and a place for just getting the hell out of a function now.

                            J 1 Reply Last reply
                            0
                            • C CurtD

                              As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

                              S Offline
                              S Offline
                              Shog9 0
                              wrote on last edited by
                              #15

                              I set up VS to draw guidelines at 80 and 120 chars. I stop at or around 80 for comments, and try to stay below 120 for code. Generally, this keeps it easy to read - i don't care how wide your screen is, i doubt your field of vision is really wide enough to take in much more than that without a lot of left-right scanning. And, i do like to print out code now and then, without having to wrap lines or shrink the font down.

                              D 1 Reply Last reply
                              0
                              • C CurtD

                                As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

                                V Offline
                                V Offline
                                V 0
                                wrote on last edited by
                                #16

                                We don't have that rule here... :-) Feel free to apply :laugh:

                                V.
                                Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                                1 Reply Last reply
                                0
                                • C CurtD

                                  As a contractor/consultant, I have worked in a lot of places over 25 years. Without fail, everyone of them has had a rule that source code should not exceed 80 chars per line. I've always asked if this is because they are backing everything up to punched cards. Back in the Win 3.1 days, they would tell me that there was always some asshole who used DOS edit (or even edlin) for writing code. I always thought this was a good reason to suggest that they pursue another career. Now in the VS 2005 IDE, with my widescreen monitor, even with some toolbars added to the sides, 80 chars doesn't even go half way across my screen. And yet, we still have the 80 char rule (which I completely ignore). Hell, even the mainframe printers from the 1960's would print 120 chars (I think -- that was a lot of beers ago, but I know it was > 80). If you are still writing code in an 80 char mode editor or using a dot matrix printer, there are plenty of jobs at McDonalds (or the Smithsonian perhaps). People need to stop blindly following rules that make no sense. This is an especially bad problem with computer nerds. If no one can explain why a rule exists, then get rid of it and ignore it until someone does.

                                  S Offline
                                  S Offline
                                  Stuart Dootson
                                  wrote on last edited by
                                  #17

                                  You need a limit somewhere - I agree that a hard limit of 80 is a little low, but I'm working with a code generation tool at the moment - it generates some lines of with more than 400 characters - that's a bit on the long side :-) Looking at *my* code, my hard limit seems to be about 150 characters, but I try to use multi-line and indentation if a statement goes over about 100 characters. I just try and make the code reasonably readable, without unnecessarily fragmented lines.

                                  1 Reply Last reply
                                  0
                                  • S Shog9 0

                                    Exactly. It's a good guideline, in that returns deep in the bowels of the code just make it harder to follow... but common sense dictates there is a time and a place for just getting the hell out of a function now.

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

                                    Especially from the function dodge() ;)

                                    -- Kein Mitleid Für Die Mehrheit

                                    1 Reply Last reply
                                    0
                                    • L Lost User

                                      Christian Graus wrote:

                                      See, while I disagree with this as a requirement, 99% of my functions do have only one return statement, it is a good principle to aim for, what's wrong is when it becomes a hard and fast rule and you have to write code around the rule.

                                      What I really disliked about this rule was code that should look like this void Function(int param) { if(param < 0) return; //lots more code } now becomes void Function(int param) { if(param >= 0) { //lots of code } //nothing here } I found that often the "real work" of the function would be many levels of indentation deep

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

                                      the defensive coding against that sort of standard is to move all the validation into a separate function, so that you only have level of indent. bool FooValidator(...) { bool retVal = true; reval &= cond1; reval &= cond2; ... return retVal; } void Foo(...) { if (ValidateFoo(..)) { ... } }

                                      1 Reply Last reply
                                      0
                                      • S Shog9 0

                                        I set up VS to draw guidelines at 80 and 120 chars. I stop at or around 80 for comments, and try to stay below 120 for code. Generally, this keeps it easy to read - i don't care how wide your screen is, i doubt your field of vision is really wide enough to take in much more than that without a lot of left-right scanning. And, i do like to print out code now and then, without having to wrap lines or shrink the font down.

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

                                        Where is that option at?

                                        -- Join the Campaign to Help Stamp Out and Abolish Redundancy The preceding is courtesy of the Bureau of Unnecessarily Redundant Repetition Department.

                                        S 1 Reply Last reply
                                        0
                                        • D Dan Neely

                                          Where is that option at?

                                          -- Join the Campaign to Help Stamp Out and Abolish Redundancy The preceding is courtesy of the Bureau of Unnecessarily Redundant Repetition Department.

                                          S Offline
                                          S Offline
                                          Shog9 0
                                          wrote on last edited by
                                          #21

                                          Registry hack: http://blogs.msdn.com/saraford/archive/2004/05/05/257953.aspx[^]

                                          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