Slashdot Mirror


Ask Slashdot: Do Coding Standards Make a Difference?

An anonymous reader writes "Every shop I've ever worked in has had a 'Coding Style' document that dictates things like camelCase vs underscored_names, placement of curly braces, tabs vs spaces, etc. As a result, I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms. Are there any documents or studies that show a net productivity gain for having these sorts of standards? If not, why do we have them? We live in the future, why don't our tools enforce these standards automagically?"

430 comments

  1. After 42 yrs programming I say... by rs79 · · Score: 5, Insightful

    ...yes but not very much a all. Nothing beats clear thinking.

    --
    Need Mercedes parts ?
    1. Re:After 42 yrs programming I say... by man_of_mr_e · · Score: 5, Interesting

      Coding standards were largely developed to prevent developers from reformatting each others code in a format war.

      Joe works on code, checks it in. Bill gets a task to work on that code, doesn't like Joe's formatting, so he reformats, checks that in.. Joe works on the code again, finds it's been reformatted, then he reformats it again.

      This is hell when doing diff's and figuring out what changes from version to version. Coding standards help to prevent that.

      Another reason for coding standards is to set a level playing field for everyone.

    2. Re:After 42 yrs programming I say... by casings · · Score: 1, Informative

      Most diffs can ignore whitespace...

      I don't understand your second point.

    3. Re:After 42 yrs programming I say... by gantzm · · Score: 5, Insightful

      Can't agree with "not very much at all".

      I don't really care what coding standard you use, pick one any one. But here's the rub, pick one and stick with it.

      I get really exhausted and tired having to jump between 4 or 5 completely different coding styles in the same project. And I'm not just talking about indentation and formatting. I'm talking about how problems are solved.

      For example: If you're coding in Java and the "style" is to Using Apache StringUtils for what it does, then use that. Don't go create your own monster mess that does the same thing, then force me to take 15 minutes to figure out you re-wrote StringUtils for no damn good reason.

      I've watched developers struggle with this and waste hours upon hours tracking down bugs because of stuff like this. And, you know what? They never want to admit it's because the code is a typographical mess that puts your eyes into unending calisthenics.

      --


      Excessive forking causes un-wanted children.
    4. Re:After 42 yrs programming I say... by DickBreath · · Score: 2

      Coding standards make code easier to read. In many shops they are probably unnecessary. But there are outliers where code is completely unreadable. I remember in the 1980's seeing a guy's Pascal code that was formatted as if it were assembler. (Yes, I'm serious.) That is why coding standards are needed, why they CAN make a productivity difference, but in most cases, not much.

      It's too bad we can't have clear thinking standards.

      --

      I'll see your senator, and I'll raise you two judges.
    5. Re:After 42 yrs programming I say... by Decameron81 · · Score: 5, Interesting

      THE reaSON WHy coDiNg standards_exist is thatTheyIncrease THE_REaDABILITY oF YOur cODe.

      --
      diegoT
    6. Re:After 42 yrs programming I say... by XxtraLarGe · · Score: 1

      Most diffs can ignore whitespace...

      Yeah, but they don't understand that myVar and my_var are actually supposed to be the same variable...

      --
      Taking guns away from the 99% gives the 1% 100% of the power.
    7. Re:After 42 yrs programming I say... by casings · · Score: 3, Insightful

      Personally if you have a coder using myVar and my_var for two different variables in the same code, I think you have more to worry about that coding style.

    8. Re:After 42 yrs programming I say... by BasilBrush · · Score: 5, Insightful

      Most diffs can ignore whitespace...
      I don't understand your second point.

      You didn't understand his first point.

    9. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 1

      A while ago, my father-in-law had a bathroom re-done. The shower pan was to be tiled. After hearing about the problems folks had with shower pans and seeing how the installer was laying out the work, he tactfully asked about the 1/4" per foot slope, placement of tacks for the liner, and other things that usually go wrong with shower pans. He bellowed, "I've been doing this for 30 YEARS and NOBODY has complained!"

      The plumber was near by and over-heard and mentioned IPC and IRC code about pans.

      Years ago, I was collecting taxes. The tax collector would shove into people's faces how he had over 20 years of experience collecting taxes. One day, I picked up the book of the tax code set by the state's legislature and found that he talked out of his ass most of the time. And as a matter of fact, the city's corporate council hated his guts for the stupid shit he did. But, he was the Mayor's Asshole buddy.

      tl;dr - Experience means nothing if you've been doing it wrong for all those years.

      And on topic: without coding standards, I've seen folks look to the obfuscated coding champs as idols to be emulated.

      "Look! I coded this entire program on one line! See?! One semi-colon!"

    10. Re:After 42 yrs programming I say... by blackm0k · · Score: 1

      Most diffs can ignore whitespace...

      Using subversion, specifically 'svn blame' doesn't have such an easy time with whitespace. Sometimes I want to know who changed a line last (and created a bug) and re-indenting significantly reduces the value of that information.

    11. Re:After 42 yrs programming I say... by casings · · Score: 1

      Not sure if you are being serious with your point or not due to your case changes, but I will bite.

      Just because a style is standardized doesn't mean your code is more readable using that style. In fact a lot of the styles expected of me made my code less clear, and when I chose to ignore them, my code was never touched in code reviews, because everything was clear and intuitive without conforming directly to the style.

      If you personally like clear / readable code, then no standard will ever be a replacement for you.

    12. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 3, Funny

      You're probably the finicky person who keeps complaining about my rot13 variable names. To each their own, buddy.

    13. Re:After 42 yrs programming I say... by casings · · Score: 5, Insightful

      Assigning blame to people because of bugs is in fact one of the most detestable things you can do in software development. Bugs will always exist, no matter what coding style you use. If your first priority is to name and shame and not fix the code and move onto the next issue, then your teammates are going to hate you.

    14. Re:After 42 yrs programming I say... by blackm0k · · Score: 5, Insightful

      Not to name and shame, to know who to ask about what they were exactly they were doing when they changed that bit of code. You know, so my fix doesn't break there changes.

    15. Re:After 42 yrs programming I say... by IAmGarethAdams · · Score: 2

      What if you have one coder using project_cost and another using projectDeadline, and this lack of consistency is continued across the whole set of functions and variables in the project?

    16. Re:After 42 yrs programming I say... by IAmGarethAdams · · Score: 5, Funny

      (I know, I know, it means you must be a PHP developer)

    17. Re:After 42 yrs programming I say... by casings · · Score: 1

      Sorry, it was your wording in your original statement which made me assume that you were talking about this horrible practice. I definitely agree that knowing who originally coded something in order to find out their logic is extremely important, especially for those little bugs, just have a horrible aversion of people on my teams pointing fingers at each other instead of actually doing their jobs.

    18. Re:After 42 yrs programming I say... by bartoku · · Score: 1

      Personally if you have a coder using myVar and my_var for two different variables in the same code, I think you have more to worry about that coding style.

      I believe he was referring to Joe using camel case, myVar, and then Bill later fixing it to snake case, my_var. As a result the diff would mark this change as a difference since it was more than a white space change. This is as opposed to Joe placing his curly brackets on the same line as his if statements and Bill moving them to the line below white space changes.

      White spacing changes are no longer a big deal with modern IDE's able to reformat to your desired white spacing, but I have not seen an IDE option to correct camel case to snake case.

    19. Re:After 42 yrs programming I say... by Decameron81 · · Score: 4, Informative

      Not sure if you are being serious with your point or not due to your case changes, but I will bite.

      Just because a style is standardized doesn't mean your code is more readable using that style. In fact a lot of the styles expected of me made my code less clear, and when I chose to ignore them, my code was never touched in code reviews, because everything was clear and intuitive without conforming directly to the style.

      If you personally like clear / readable code, then no standard will ever be a replacement for you.

      You're missing the point. I am not claiming a particular coding style is superior, I am claiming a standard coding style across the whole code base is good - personal preferences aside.

      PS: I'm talking about basic stuff here, such as having standards on how to name variables, constants, camel case?, self documenting code?, etc.

      --
      diegoT
    20. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 1

      And you're probably the guy that never really does maintenance on other people's cryptically written code.

    21. Re:After 42 yrs programming I say... by blackm0k · · Score: 1

      Yeah, I didn't make it clear in my original comment. Especially because I used the 'svn blame' command, as opposed to the less loaded 'svn annotate'.

      I need to learn to be clearer in my wording, especially on the Internet, where nobody knows you're a dog.

    22. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      speaking of typographical messes ^^^^

    23. Re:After 42 yrs programming I say... by Tmann72 · · Score: 1

      Amen to that. I edit the code of others on a daily basis, and I'd have to agree completely. High level languages are expressive for a reason, and using clear variable names and code formats can easily speed things up. Our computers these days are incredibly fast, and come supplied with a considerable amount of memory, and while there do exist situations where that isn't the case it has still largely become the norm. There is no reason we can't optimize our code style for readability and for performance at the same time. I dare say that's ultimately what all developers should strive for.

    24. Re:After 42 yrs programming I say... by UnknownSoldier · · Score: 5, Insightful

      Exactly!

      After you use a few different coding standards an experienced developer doesn't care _what_ the actual standards (such as http://en.wikipedia.org/wiki/Indent_style ) , just as long as EVERYONE follows them.

    25. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 3, Interesting

      I have a coding standard. The coding standard is,

      1. use tabs for indentation, spaces for alignment.
      2. put a space after a comma

      Basically, so shit is readable. There are coding standards for English too. That you put a space after punctuation and that you start a sentence with a capital. Yeah, people still fuck up grammar. They still write run-on sentences. They still can't spell.

      There is nothing special about code that hasn't already happened in regular languages. Having a simple, easy to follow coding standard is OK. Being over the top is a little unproductive but then it depends on the size of the project. There may be a different rigor when adhering to your workplace's coding standard vs. something like Linux kernel.

      So yes, coding standards make a difference if there is more than 1 developer involved.

    26. Re:After 42 yrs programming I say... by jimbolauski · · Score: 1

      The only real good argument for rigid formatting is in the help descriptions for function definitions and variable description when you have an automated help. If a programmer needs a style guide to tell them they shouldn't use a,b,c,d... for variable names, have 100 line functions, have useless comments littered throughout the code, or as you said reinvent the wheel with some minor twist that the developer failed to foresee then they are in the wrong business.

      --
      Knowledge = Power
      P= W/t
      t=Money
      Money = Work/Knowledge so the less you know the more you make
    27. Re:After 42 yrs programming I say... by daenris · · Score: 3, Insightful

      You assume that formatting refers only to whitespace, but given the larger context of the conversation, I believe he's using formatting to refer to the whole of the standards (variable name conventions, spacing, brace position, etc).

    28. Re:After 42 yrs programming I say... by XxtraLarGe · · Score: 1

      I believe he was referring to Joe using camel case, myVar, and then Bill later fixing it to snake case, my_var.

      Yes, that's exactly what I was referring to. The example was purposely simple.

      --
      Taking guns away from the 99% gives the 1% 100% of the power.
    29. Re:After 42 yrs programming I say... by djchristensen · · Score: 1

      It's not as simple as that. Sure, everyone is going to have bugs in their code, but some are much worse than others. No accountability at all can be just as detestable as incessant finger-pointing.

    30. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      If you've seen enough coding standards, you no longer even care if the code base has the same standard, since you seen them all before. Unnecessary churn due to style changes in part of the code still matter of course due to the inefficiencies they create, but consistency across the code base shouldn't.

    31. Re:After 42 yrs programming I say... by zakkudo · · Score: 2

      When someone makes a generic list of bullets, only some of them may apply to you. Some of them may have been made from experience in different situations or time periods.

      It tends not to be constructive latching onto a single bullet screaming "It doesn't apply to me!!!" over and over and over again.

    32. Re:After 42 yrs programming I say... by casings · · Score: 3, Insightful

      And you're missing my point when I say that just because a particular style is standardized doesn't mean it produces self-documenting code. If the person in charge of setting the standard is an incompetent programmer to begin with, then his standard could introduce confusion. There are many examples of this happening on the daily wtf. And in fact, I have had managers that have tried to enforce standards which would turn my code from easily understandable to a mess of variable acronyms.

      To a competent programmer, stardards are more of a guideline. Any good coder knows how to produce clear and maintainable code, and should be able to read similarly clear code even if the case of the variables are different or there is an endline after the curly braces. Bad coders need and cling to these rules, however, because without them they would literally have no idea what to do.

    33. Re:After 42 yrs programming I say... by AwesomeMcgee · · Score: 1

      Which is why thank the lords some languages have grown common standards that are fairly industry wide, that's probably the thing I love about C# more than anything else, I can wander GitHub from one project to another from one author to another with no relation between them and I never have to decipher somebody's layout or the intention of their style because it's 98% identical.

    34. Re:After 42 yrs programming I say... by casings · · Score: 1

      I'm not seeing the issue. If a dude is changing variable names, then I would want to know about it as that is less trivial than whitespace changes.

      This seems like another productivity issue. If I have a guy focusing on changing variable names from myVar to my_var, then he's either going to be talked to and told to wisen up or canned as he's not doing anything productive.

    35. Re:After 42 yrs programming I say... by luis_a_espinal · · Score: 1

      Most diffs can ignore whitespace...

      I don't understand your second point.

      Differences in coding standards go beyond whitespace. One thing I've liked to do when doing code reviews or when working with disparate teams (or when working with changes to legacy code where the changes are meant to do incremental improvements on the existing quality) is to take the file versions to be inspect them, run both through GNU indent (I don't give a shit about what style GNU indent pics, I just care to make sure both get indented with the same rules) and then do the diff.

      Another practice has been to always run your code through an indenter prior to checking changes to source control. Developers are free to indent and reindent as they please, but the final stuff to be put on source control is under a master style. Put some aliases or scripts that do the checking in and out with an automatic re-indentation in place, and off you go. That practice has saved me/us a lot headaches.

      I mean, there is nothing worse than somone doing an accidental re-formatting during development and then submitting to source control, followed by more changes now under a new style format. Then it comes time to merge, oi vey, how joyful.

      Then it is a PITA (a solvable, but still annoying and sometimes time consuming PITA) to find out what the hell actually changed.

      This is even more important when you have to work with legacy code written eons ago by people who had no sense of aesthetics or even anything that remotely resembled common sense and code organization, under conditions that prevent a mass re-indentation of files.

    36. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      A little defensive... guess you are sloppy coder that gets busted a lot.

    37. Re:After 42 yrs programming I say... by luis_a_espinal · · Score: 4, Insightful

      And you're missing my point when I say that just because a particular style is standardized doesn't mean it produces self-documenting code.

      But that's not what you were arguing first. You were arguing that diffs can handle differences in whitespaces (and obviously, indentation is more than just that.) Maybe I'm missing the point you are trying to make. Standarization is not a necessary condition for self-documenting code, but that's not what they are for. Styles are for having a normalized structure with which to collaborate. Self-documenting code is a related, but different issue altogether.

    38. Re:After 42 yrs programming I say... by casings · · Score: 1

      Brace position and spacing both are encompassed by the whitespace argument that I was referring to. Also I would say that if you have a programmer who chooses to change the variable names of their inherited code simply because it doesn't conform to the standard, then I would say you have more to worry about than coding style.

    39. Re:After 42 yrs programming I say... by mk1004 · · Score: 2

      We live in the future, why don't our tools enforce these standards automagically?

      They would, but they are held up in code review.

      --
      I can mend the break of day, heal a broken heart, and provide temporary relief to nymphomaniacs.
    40. Re:After 42 yrs programming I say... by casings · · Score: 1

      I don't disagree that there needs to be at least some level of tracking (usually the kind inherent in most source control software). As stated in another reply, understanding the programmers original logic can greatly help things. I agree that it can also help you find the source of malicious code.

    41. Re:After 42 yrs programming I say... by luis_a_espinal · · Score: 1

      Personally if you have a coder using myVar and my_var for two different variables in the same code, I think you have more to worry about that coding style.

      It's easy to get that when you have different people inheriting source code. Also, you are right that there are more important things to worry about in such a situation. Barring firing everyone and replacing them with the best, how do you solve that? There are many ways to solve, and some of them involve having a coding style. They are not the silver bullet people make them to be, but they have their useful place in the industry. They are just tools, that can be used or abused.

    42. Re:After 42 yrs programming I say... by bartoku · · Score: 1

      I'm not seeing the issue.

      You are missing the point of the post by man_of_mr_e and the reply from casing.
      man_of_mr_e wanted to dismiss formatting issues as not a big deal to diff in the version control, claiming diff is smart enough to handle it; an interesting assertion.
      However, casing cleverly pointed out that man_of_mr_e was missing the issue of case formatting and how diff would probably choke on it.

      If a dude is changing variable names, then I would want to know about it as that is less trivial than whitespace changes. This seems like another productivity issue. If I have a guy focusing on changing variable names from myVar to my_var, then he's either going to be talked to and told to wisen up or canned as he's not doing anything productive.

      I agree that if productivity is in question then it would be nice to know. However I would disagree that productivity issues should clutter a version diff though.

      Imagine the scenario where my IDE can quickly switch code from camel case to snake case and give me the white spacing I am most comfortable with. If with a key stroke Bill can alter Joe's code to be more readable for Bill and that in turn improves his efficiency, then why not? Correspondingly then Joe should be able to flip it write back when he has to work on Bill's code.

      Now you are worried about the situation where Bill picks up Joe's code and spends his morning moving curly brackets to a new line and converting camels to snakes manually. Probably not the best use of Bill's time for you, and even if arguably the time spent converting Joe's code manually makes Bill more productive it was not a total time well spent. Now surely Bill is good enough to read Joe's formatting, but if it pisses him off, well then perhaps a few hours is worth keeping Bill happy? I mean Bill is a good guy, a great programmer, he is just set a bit in his ways and opinionated. Bill is still making his deadlines, no worries.

    43. Re:After 42 yrs programming I say... by bartoku · · Score: 1

      Oops I meant XxtraLarGe, not cassings.

    44. Re:After 42 yrs programming I say... by casings · · Score: 1

      Well my argument to man of mister e and first reply to Decameron are two different arguments.

      My argument to man of mister e, was simply to imply that using features in your diff program can help you ignore meaningless differences in styles.

      My argument to Decameron was in reply to his blanket statement that "the reason why coding styles exist is that they increase the readability of your code." This is an absolute statement about the nature of coding styles, which is factually incorrect, as I have demonstrated by personal experience as well as well known failures from the daily wtf.

    45. Re:After 42 yrs programming I say... by gantzm · · Score: 1

      Well, there are a lot of people that shouldn't be in the business.

      --


      Excessive forking causes un-wanted children.
    46. Re:After 42 yrs programming I say... by casings · · Score: 1

      You assume incorrectly. This is common sense.

    47. Re:After 42 yrs programming I say... by wierd_w · · Score: 1

      Some conventions make more sense to me than others.

      Some conventions say only the first letter of variables should be capitalized, for instance.

      $Therepistname

      Some say the whole word should be capitaized...

      $THERAPISTNAME

      Some say not to include a type descriptor, so that variables can be cast as new types on the fly as needed...

      Therapistname

      Some say that each word in the variable should be capitalized...

      TheRapistName ..........

      Personally, I like to include the type descriptor prefix, and capitolize each word in the variable, ad use all caps for functions, routines, and commands.

      SORTPERPLIST ($NamesOfPerps())
      ADDPERP ($TheRapistName, $NamesOfPerps)

      Etc.

      But that is just personal preference. I don't like having to explain ambiguity over named variables, when I can clearly convey the intent with $Therapist and $TheRapist.

      Trust me. Answering those questions can get quite akward!

    48. Re:After 42 yrs programming I say... by casings · · Score: 1

      Well I would actually say that changing variable names simply because they don't comply with the standard isn't only a productivity issue. It is bad practice and a productivity issue. I would want the diff to show the change for two reasons. 1. it isn't a trivial change to change a variable name like it is to change whitespace. This can introduce bugs. 2. the productivity issue.

      I would also say that I would never, ever, ever use an IDE which would change the actual variable names and not just the whitespace. Bill sounds like he needs to attend anger management if a style change makes him angry.

    49. Re:After 42 yrs programming I say... by casings · · Score: 1

      If you're referring to two different local variables of two different functions, then obviously that is the case, and the change in the styles shouldn't matter, as they are in fact two different variables.

    50. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      THE reaSON WHy coDiNg standards_exist is thatTheyIncrease THE_REaDABILITY oF YOur cODe.

      Beginning programmers are notorious for poor practices when writing code regardless of the presence or absence of a 'coding style guide'. Using every shortcut feature of Perl does not make them better programmers; name your variables.

    51. Re:After 42 yrs programming I say... by casings · · Score: 1

      Who are you referring to?

      I saw two arguments from the first guy, and I addressed both of them.

    52. Re:After 42 yrs programming I say... by PRMan · · Score: 1

      I had a guy do this once. We didn't have any coding standards. He stayed up all night to reformat my code into his format, which he somehow thought was superior (braces on the same line, spaces inside parens, etc., etc.) and checked it in.

      The next time I checked it out, it was completely different and made it difficult to compare histories (he actually introduced a bug with his reformatting).

      So I hit Ctrl-K Ctrl-D so I could compare it, found the bug and checked it back it.

      He came to my desk angry and said I couldn't win because he would never stop so I might as well give up. He spent all night again and checked it in.

      I came in in the morning and saw that it was different. I hit Ctrl-K Ctrl-D and checked it in.

      He spent a couple hours and worked through lunch and when I came back from lunch, he told me that he had done it again and I should just give up.

      In front of him, I checked it out, hit Ctrl-K Ctrl-D and checked it back in. He asked me, "How did you do that?" I told him that he could set his settings in Visual Studio to see it however he wanted.

      Anyway, because he had wasted so much time (and charged overtime!), they asked me to make a coding standards document, which I put 2 or 3 things in and for everything else said "Windows default style".

      So that's why you have coding standards. Even though I made them, it wasn't my fault.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    53. Re:After 42 yrs programming I say... by VortexCortex · · Score: 4, Informative

      Brace position and spacing both are encompassed by the whitespace argument that I was referring to.

      Except that a diff isn't going to ignore whitespace when broken across multiple lines, verses a one liner. See also: Python.

      You're preaching to the choir, btw, but also you're making the wrong argument. Whitespace does matter, it just shouldn't matter how it's configured, just that it's consistently applied.

      The reality of the situation is that if I reformat a 100 char line to be broken across lines with max 80 chars, and go back and forth doing this it thrashes the code repository. Diffs are general purpose, they don't understand code syntax, you've used them haven't you? Newlines are whitespace. They don't lexically parse code ignoring all whitespace, they work line by line. However, Compilers DO understand their own syntax! IMO, all compilers should have the option to lex & reformat inputs to whatever style you want based on an input rule sheet of some kind. Currently this is handled disparately in a non standardized way by IDEs, scripts, etc. In fact, many projects will have a script or program that you should run your code through before committing it. This allows you to code however you like, while giving the codebase a consistent and uniform look.

      Any moron complaining about whitespace in code doesn't really belong in coding.

      I find this statement moronic and/or ignorant. If you don't think that a uniformity and consistency help while reading and understanding text (including code), then you've never studied the human brain much at all. We're pattern matching machines. If the patterns change from page to page then it IS actually harder to read. The first thing I usually do when working on a new project is equip my editor/IDE with a style guide for the project to transform all code into my preferred style while editing. Then I can edit in the pattern than I'm most used to dealing with -- It's faster because that's how brains work. Being more efficient and taking advantage of my brain's natural tendencies isn't moronic, it's smart.

      On save, or before commit the code is transformed into the project's style guide by an auto formatter. I think this is the best, because I have cognitive science research to back it up, repetition of tasks builds "muscle memory", etc. So, my use of whitespace rules is actually faster than adapting to each project. Now, given that we don't have all compilers with such option to transform data on the fly to our preferences, and we can't always rely on the other coders to be using IDEs that can do this, the next best thing is having a project wide coding standard, and that's exactly what we do. Seriously, what sort of experience do you have where you haven't run into this commonality yourself? What's more likely that everyone is wrong but you or that we've all been down the road before and have arrived at a common consensus? Level up your knowledge. To me you sound rather ignorant and quick to make assumptions, thus foolish.

    54. Re:After 42 yrs programming I say... by obarel · · Score: 1

      Oh, you mean 'svn praise' ;-)

    55. Re:After 42 yrs programming I say... by bartoku · · Score: 1

      Bill sounds like he needs to attend anger management if a style change makes him angry.

      I will let you inform him of that when I am not around...

    56. Re:After 42 yrs programming I say... by Decameron81 · · Score: 1

      Well my argument to man of mister e and first reply to Decameron are two different arguments.

      My argument to man of mister e, was simply to imply that using features in your diff program can help you ignore meaningless differences in styles.

      My argument to Decameron was in reply to his blanket statement that "the reason why coding styles exist is that they increase the readability of your code." This is an absolute statement about the nature of coding styles, which is factually incorrect, as I have demonstrated by personal experience as well as well known failures from the daily wtf.

      I can definitely meet you half way there - I agree that bad coding standards suck (too precise, too complex, unreadable syntax), and make the code a mess. I'm speaking out of experience as well, working in all kinds of projects. Some of them had some pretty awful coding standards that didn't improve readability at all. But I was talking about the _purpose_ of standards. I still stand by my statement that the purpose why they exist is to make the code more readable - even if some implementations suck.

      Think of it as something along the lines of: "the reason why testing is important is that it helps you find bugs". Bad testers don't invalidate that statement.

      --
      diegoT
    57. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      to name and shame is for some hardly distinguishable from friendly advice on 'coding style'. The same comment can be taken as an offence by some and by others be seen as a professional way to tell you there is room for improvement. Secondly some people do not understand a friendly advice unless told explicitly that they 'f*ed up (again)'. It is good that people ask and get interest in this. Only I doubt it makes any difference - the cost and savings are timely, geographically and sometimes organizationally so far apart that people forced to improve would reject a request out of principle especially in big organisations that is true.

      Eh humans

    58. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Not to name and shame, to know who to ask about what they were exactly they were doing when they changed that bit of code. You know, so my fix doesn't break there changes.

      If the code is so poorly written and documented that you could introduce new code elsewhere which breaks the pre-existing code there are larger issues. Most programmers, regardless of experience level, are terrible at writing maintainable source code. On one project that I inherited at the 3/4 schedule mark was so terrible it was easier to start from scratch and complete the project in 3 months so the system was delivered on time. The original code would have required more patching and workarounds and pushed the delivery well beyond the drop-dead date.

    59. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Most diffs can ignore whitespace...

      Not most diffs I've worked with...

    60. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      You're completely misunderstanding what svn blame is for. I use it all the time to find out when a piece of code was changed, and see how it changed from the previous revision. Combined with commit messages, bugtracker IDs in the commit messages, and seeing what other pieces of code were changed with the same revision, I can usually find out why it was changed, and what I need to watch for when making changes to the same piece of code so that I don't break something.

    61. Re:After 42 yrs programming I say... by lgw · · Score: 5, Insightful

      Is it better to drive on the left side of the road, or the right side of the road? There might be some argument to be made that one is better due to most peopl ebegin right-handed, but it's not going to make much of a difference.

      But it's really important that everyone drives on the same side of the road.

      It's simply faster and easier to read code that has style standards followed throughout. Even when they're pretty stupid.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    62. Re:After 42 yrs programming I say... by casings · · Score: 1

      I will happily meet you in the middle about their intended purpose, and I wouldn't have argued with Decameron if he had stated his opinion in your way. The problem was he didn't leave room for the possibility that they don't actually fulfill their intended purpose in his statement.

    63. Re:After 42 yrs programming I say... by casings · · Score: 1

      Wow i meant this to be a reply to Decameron, and I didn't even realize it was him who replied to me. Sorry, man, didn't mean to refer to you in the third person.

    64. Re:After 42 yrs programming I say... by Decameron81 · · Score: 1

      But I'm Decameron! ;-)

      And yes I understand what you're saying. Given how you mentioned that writing clear and readable code is important no matter what coding standards you have, I also suspect we may not even think that differently (even if my initial statement sounded a bit more black vs white that I wanted).

      One of the coding standards that I require from my teams (whenever the decision falls on me, of course) is to write self-documenting code, and avoid abbreviations as much as possible (among other requirements, but not that many). Usually just enough rules to guide an inexperienced dev towards writing more readable code - better code's another story of course.

      Regards.

      --
      diegoT
    65. Re:After 42 yrs programming I say... by Fastolfe · · Score: 4, Informative

      Disagree. There are different naming conventions for things like constants and class members. The point of these conventions is to make it clear from the name of the variable what the variable represents. If you aren't confident that the code base is consistently following the same conventions, you have no confidence that something that appears to be a local variable is actually a local variable, which means you need to spend more time poking through code in order to understand it.

      Consistency begets readability, and readability begets maintainability.

    66. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      I used to say that, but I've since come to realize that while it's true that there are many choices that will work, there definitely are also coding styles that are simply a terrible idea. 8 space indent is a great way to ensure that only people with wide screen monitors can read your code and to prevent even those people from having 2 files open side-by-side. Allowing mixed tab/space for indentation is a nightmare too. RdicAbbrevEvryw is terrible too. Are you really happy to wordCode wordIn wordHungarian wordNotation? How about a C++ coding style that says "only use const if you must to satisfy the compiler, such as when using STL comparers"? How about useminimalpossiblewhitespace? How about "use only strictly necessary parens - everyone should have memorized the C++ operator precedence by now"? There are plenty of terrible choices to make in a coding style!

    67. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      You missed the point. It's not about one programmer using two names like that. It is about one programmer who likes to use underscores changing the names used by the other programmer who likes to use camel case. The differently-named variables always meant to be the same concept, but the diff thinks they are different.

      Why am I commenting? This is too obvious.

    68. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 1

      Are we talking *everyone* on the same side of the road? I imagine there would be a great increase in accidents...

    69. Re:After 42 yrs programming I say... by Darinbob · · Score: 1

      What's important is not that everyone agrees with everything in the coding standard, but that all the team members are consistent.

      You can often spot who's going to be easy to work with and who's going to be an annoying team member, based on how strenuously they object to something in a coding standard.

    70. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 2, Insightful

      Exactly!

      After you use a few different coding standards an experienced developer doesn't care _what_ the actual standards (such as http://en.wikipedia.org/wiki/Indent_style ) , just as long as EVERYONE follows them.

      A big plus one to that.

      This is what annoys me about the original question -- the OP is getting upset over someone else dictating how he formats code, and calling them a pedant for fixing it, without seeing his own hypocracy, where he's too inflexible to accept the standards that are already in place.

    71. Re:After 42 yrs programming I say... by seebs · · Score: 1

      While in theory it's true, so far I have never, ever, seen any coding standard, however horrific, that was worse than code which had no conventions or standards at all.

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
    72. Re:After 42 yrs programming I say... by UnknownSoldier · · Score: 1

      > Allowing mixed tab/space for indentation is a nightmare too.

      Agreed. The correct usage is:

              Spaces for indentation, Tabs for alignement, because ALL text editors are still too stupid to understand dynamic tab stops!

      > there definitely are also coding styles that are simply a terrible idea.

      I've found over the years as I've tried various coding standards that they all have _some_ merit. Usually because a programmer was trying to solve a particular problem and didn't want anybody else to fall into the same trap -- so he made a religion out of it !

      That is some of those are based on ideology instead of practicality (cargo-cult mentality.) Or said another way:

          "Any ideology taken to an extreme is usually never a good idea in the long run."

      An expert needs to balance anarchy (no rules) with structure (rules). That is, an expert, knows WHEN _to_ and when _not_ to break the rules. ;-) The reason Microsoft Hungarian notation SUCKS is because somebody went to the extreme and didn't understand what the fuck they were doing -- forcing everyone to become a partial compiler. Joel has a rant on this: http://www.joelonsoftware.com/articles/Wrong.html

      const char * pszText = "Hello World";

      What the fuck does 'sz' even add EXCEPT NOISE. You don't care that the compiler has to zero-terminate a string. We ALREADY can tell it is a string by the variable -name-. All you care is about the basic types: is it a pointer? an array? an numeric?

      Instead:

      const char *pText = "Hello World"

      Is _good_ enough. It adds SOME information without getting lost in the dogma of naming.

      I personally use a modified SHORT Hungarian notation because I deal with various graphics/math types all day long.
      i.e.
      * a Array of
      * b Boolean
      * i Iterator
      * g Global
      * m Matrix
      * n any Number / Count / Sum / Total. Why the hell do you care if it is 8-bit, 16-bit, 32-bit, or 64-bits or SIGNED or UNSIGNED ?!?!
      * p Pointer
      * s Singleton
      * r Reference
      * t table/hash/object
      * v Vector
      * q Quaternion
      * _ Member variable // Only because 'm_' is too verbose. Using a single character prefix keeps everything aligned up. ;-)

      A one character prefix (for the most part) is a good balance between conveying information and minimizing noise.

      i.e. pointless contrived example to demonstrate

      // Globals
          int gnThing; // -type- and -variable- should be aligned in columns; /. eats whitespace
          Thing gaThing[ SIZE ];
       
      // I also append an underscore in parameters so people can visually tell the arguments will be getting modified.
      int Count( int & bIsFragmented_ )
      {
          bIsFragmented = false;
       
          int .. nTotal = 0; // ingore the periods; /. sucks for code formatting
          Thing *pThing = &aThing[0];
          for( int iThing = 0; iThing < gnThing; ++pThing )
          {
              if( pThing )
                  nTotal += pThing->nSize;
              else
                  bIsFragmented = true;
          }
          return nTotal;
      }

      Some of the old "standards" no longer make sense today such as limiting comments to 80 chars. We all have wide-screen monitors these days and if you are too dam lazy to learn how to toggle word-wrap in your editor maybe you should consider another career.

    73. Re:After 42 yrs programming I say... by UnknownSoldier · · Score: 3, Informative

      Yes, agree 100% !

      Simple example:

      const int SIZE = 256; // all constants are upper case
       
      #define ALIGN_DOWN(n,pow2) (n & (pow2-1)) // all macros are upper case with underscore in-between words
       
      class CContainer { // Classes are prefixed with 'C'
        int m_size;
      public:
        int getSize() const { return m_size ; } // Coding standard will mention about Brace Style and the case style. (Are one-liners getters allowed?)
      };
       
      enum EFlags { // Enums/flags are prefixed with 'E'
        FLAG_READ .= (1 << 0),
        FLAG_WRITE = (1 << 1),
        FLAG_EXEC .= (1 << 2);
      };
       
      // Ignore the periods since /. doesn't know how to keep extra whitespace in code. :-(

    74. Re:After 42 yrs programming I say... by Grishnakh · · Score: 1

      If you personally like clear / readable code, then no standard will ever be a replacement for you.

      In my experience as a software engineer, clear and readable code is a rarity in the corporate world, and most programmers just don't care about code being readable or clear. It's usually a complete mess following no standard at all, even when it's written by one person.

    75. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      True. The problem isn't the coding standards, the problem is trying to use Code Reviews as 'gotchas' to enforce code standards. That's not what Code Reviews are for, but that's what they often degrade into.

    76. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Sides of the road? Just drive on the dashed line of the road. Everyone will be pulling over, honking at you, using their fingers to tell you that you're number one.

    77. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Who needs standards?
      This is fine isn't it?

      long long n,u,m,b;main(e,r)char **r;{f\
      or(;n++||(e=getchar()|32)>=0;b="ynwtsflrabg"[n%=11]-e?b:b*8+
      n)for(r=b%64-25;e15?n:n>9?m%u*~-u:~(int)r?n+
      !(int)r*16:n*16,b=0))u=1ll6177%n--*4;printf("%llx\n",m);}

    78. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      If it's so bad, why is a feature of SVN called "Blame"?

    79. Re:After 42 yrs programming I say... by SQLGuru · · Score: 1

      Naming standards have to be adhered to for them to work, but formatting should be a macro/button press away (if it isn't automatically enforced as you code) and shouldn't be an issue.

    80. Re:After 42 yrs programming I say... by TheLink · · Score: 2

      Brace position and spacing both are encompassed by the whitespace argument that I was referring to.

      ORLY? Which diff are you using treats the following as the same?
      if (a==b) {
        doSomething;
      }
      As this:
      if (a==b)
      {
        doSomething;
      }

      As for ignoring whitespace, just hope you never inherit a python project that's written by multiple people who don't follow the same standards ;).

      --
    81. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Wrong. It's not his wording. It's your ignorance and pride that made you make incorrect assumptions.

      He specifically said "subversion" and "svn blame". Those letters and words were there for a reason. So if you had been humble enough to assume "svn" stood for something you didn't know, you could have used google, learned something and not posted out of ignorance. Subversion is not the only version control system that uses the term "blame" in that manner either.

      So stop trying to shift the blame onto him or others for your own failures.

      just have a horrible aversion of people on my teams pointing fingers at each other instead of actually doing their jobs.

      You seem to like pointing fingers too. Maybe if you were better at your job and pointed fewer fingers yourself, people on your teams would be spending less time pointing fingers.

    82. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      NOOOOOO! If everyone drives on the same side they will be constantly hitting each other head-on!! They must drive opposite each other! ;-)
      Sorry, couldn't resist. I just pictured all traffic on the same side of the road...

    83. Re:After 42 yrs programming I say... by rs79 · · Score: 1

      "Comments lie. Code never lies" - Keith Doyle

      --
      Need Mercedes parts ?
    84. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      But it's really important that everyone drives on the same side of the road.

      OK, but if everyone drives on the same side, then why even bother to make the other side of the road ?

    85. Re:After 42 yrs programming I say... by jbolden · · Score: 1

      You are mixing up a lot of things there.

      g for global is a scoping issue. I would think you make it an exception and gx where x is the normal type.

      Similarly for m and v I'd do another letter: vx where x is the components of the vector.
      Also what is reference vs. pointer?

    86. Re:After 42 yrs programming I say... by allo · · Score: 1

      but not so easy newlines. And you want to most basic diff program like in diff(1) to be able to diff the code.

    87. Re:After 42 yrs programming I say... by allo · · Score: 2

      the m_ convention is pure bullshit. Every good editor shows member variables in another color. That's it!

    88. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      This is because we all want to code in editors better suited to typewriters of the beginning of the 20th century. It the editor is not smart enough to understand what is a const, what is a typedef and what is a class - and so far, they are not - well, we deserve what we have.

    89. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Totally agree with everyone who points out the benefit of consistency. When working on a large project, keeping it all in your head and understanding what is going on is hard enough already. Different styles all over the place just add to the thinking time... "oh hang on is this a constant", or "does this leading _ mean a private variable.." etc.

      I also second that it sets a bar for quality, but doesn't on it's own enforce it. Its a good way to emphasize that you're working on a team, that other people will be reading and trying to understand your code, and that you can't just go off and do whatever you please. Once I got over my own ego and stubbornness I found coding standards to be useful in this regard.

    90. Re:After 42 yrs programming I say... by DrVxD · · Score: 3, Informative

      CodingStandardsThatMandateCamelCaseDecreaseReadability.

      coding_standards_that_mandate_underscores_increase_readability.

      --
      Not everything that can be measured matters; Not everything that matters can be measured.
    91. Re:After 42 yrs programming I say... by DrVxD · · Score: 1

      Most diffs can ignore whitespace.

      This is true - but it's not really a solution.

      Firstly, most source code management systems (quite rightly) consider whitespace to be significant, so if Bob messes around with Alice's whitespace, then as far as the SCM is concerned, it's a change (regardless of whether there's a semantic change or not). So futzing around with whitespace can lead to the appearance of considerable code churn - despite the fact that it's actually just noise.

      Secondly, ignoring whitespace in a diff can lead to false negatives - since whitespace *can* have a semantic impact.

      --
      Not everything that can be measured matters; Not everything that matters can be measured.
    92. Re:After 42 yrs programming I say... by rv_mAdZeRG · · Score: 1

      As an integration tester, I have to second what you're saying !!

      It's a real pain to integrate works done by people having a different formatting style habit. In my opinion, enforcing that everybody uses UTF-8 as a default encoding is the first rule to establish. I'm currently working with people in Mauritius and, I can understand why, some of them encode their files using UTF-16 ... It's fine but our standard is UTF-8 and, sadly, our internal SCM tools (targeting IBM Synergy 6.5a) don't like developers to mess up with that ;(

      And yes ... distributing a enforced checkstyle formatting pass automatically while integrating (preferably every night) is a must have best practice ! We use maven for that and a very special Hudson plugin : blame :)
      I know all other build managers in the world just smiled when they read the former sentence ;)

      --
      Sig ? Who's Sig ?
    93. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      I've been programming almost as long as you. I agree. Some standards regarding basic elements(style) need to be kept, but the fewer the better.
      The big reason for style standards and documenting code is maintenance and code reuse for future programmers who don't have the original coders around to talk to---happens most of the time.
      Dead code(terrible style and no documentation) has been the bane of my programming existence forever. I've done it to myself! ! !
      So thats why coding standards, just enough, help.
      Otherwise, you are right in bitching if you are on a "death march" and got to get the code out before the competition.
      Its a balancing act between now and the future!
      Have fun!!!!

    94. Re:After 42 yrs programming I say... by BobVP · · Score: 2

      And some developers are color blind, rendering that fancy editor coloring useless.

    95. Re:After 42 yrs programming I say... by Tamerlin · · Score: 1

      In my experience, the places with the most stringent coding standards have the worst code. The impression I get is that the standards were developed by programmers who couldn't program as a way of kissing ass, or by managers who thought that they knew something. At Expedia there's a style checker built into the build, so that you can't check anything in until the style checker stops complaining. The code I had inherited was, naturally, riddled with suppression directives and was basically spaghetti. Obviously the standards weren't accomplishing anything, because they don't enforce what needs to be enforced: code quality. It's the TSA approach: they provide the illusion of quality.

    96. Re:After 42 yrs programming I say... by allo · · Score: 1

      then they can configure to display it bold or something. Its not like you cannot display it any way you want with a good IDE.

    97. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      The short answer is :Yes. Well-formatted code requires 8-12% less time to maintain. You can find the research at DoD, SEI, universities, etc. I collected this stuff for two years at AIRMICS. Since 80-95% of the lifetime costs of a system is in maintenance, this is huge difference. The problem is getting people to use the right pretty printer. You need to consider eye movement and vertical as well as horizontal reading patterns. You need to know what a Bouma is and how they work. How colors work. Etc.

    98. Re:After 42 yrs programming I say... by BobVP · · Score: 1

      Lazy-man tools like colorization or IDEs are no excuse for ignoring good programming practices. After 20+ years of programming, VI/VIM is still the best "IDE" I've found personally, but without standards all those tools are just a way to be lazy.

    99. Re:After 42 yrs programming I say... by allo · · Score: 1

      and vim can help you to code, too. No need to clutter your code, when your tool can detect the semantics without naming convention.
      Naming conventions are like source comments: the code changes, the name may not. A local variable becomes member or the other way round, but nobody ensures the name is changed to reflect this.
      So its better when your tool just shows it in another way, by doing some static code analysis. The code is always the truth, everything else can be outdated.

    100. Re:After 42 yrs programming I say... by lsatenstein · · Score: 2

      I program mainly in good old C, and I use camel case. If anyone looks at my code, they will see paragraphs, (white space between different functionality). I also tend to run indent before I save the code for the production compile.

      Furthermore, I have a change log at the top of the source, and if the code has many lines, I put in an english description of what that group of functions is supposed to do.

      Sometimes I put in warnings near a code segment as reminders that some logic is there for a good reason.

      50 years in IT and I learned well from my peers. Now I am the one who they follow.

      --
      Leslie Satenstein Montreal Quebec Canada
    101. Re:After 42 yrs programming I say... by wallsg · · Score: 1

      Exactly!

      After you use a few different coding standards an experienced developer doesn't care _what_ the actual standards (such as http://en.wikipedia.org/wiki/Indent_style ) , just as long as EVERYONE follows them.

      It would be nice if the coding standards weren't changed every few years.

    102. Re:After 42 yrs programming I say... by Anonymous Coward · · Score: 0

      Every good editor shows member variables in another color. That's it!

      Assuming all of your developers use the same editor...

      In many development organizations, developers are given the freedom to choose their IDE - especially if doing cross-platform development.

      You can't depend upon the fact that VisualStudio displays code one way, but XCode does it differently, and Eclipse does it a third. What about the hard-core folks using vi, emacs, or any other manner of pure text editor?

      Anything that contributes to readability across your development organization is valuable. If it happens to be the m_ convention, so be it. Just don't depend upon everyone using the same environment.

    103. Re:After 42 yrs programming I say... by allo · · Score: 1

      no, not the same editor, only the same feature. every IDE does, a good configured vim does as well. So where is the problem.

    104. Re:After 42 yrs programming I say... by ArsonSmith · · Score: 1

      Wasn't part of the question, why cant the IDE take care of this? should be easy for it to store a table of VAR1="my var" then have a way of changing it to myVar when loaded into one persons view and my_var when loaded into someone else's view.

      --
      Paying taxes to buy civilization is like paying a hooker to buy love.
    105. Re:After 42 yrs programming I say... by DutchUncle · · Score: 1

      Coding standards are not the solution.

      You have a typo in your post - "there" instead of "their". No coding standard is going to notice that. While people are busy looking for indentation and camel case, they are NOT looking for whether you used the correct variable. Maybe a static analysis program would question it; maybe not.

      I find that clarity of meaning to humans tends to lead to clarity of meaning to the compiler as well.

  2. "a net productivity gain"..YES by who_stole_my_kidneys · · Score: 5, Insightful

    because when you leave\get fired\DIE, everyone can read your code and not have to interpret it, thus productivity gained.

    1. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 4, Insightful

      I have inherited metric craptons of code. Variable declarations and naming conventions were NEVER the problem I had. It was spaghetti code. It was unfactored code. It was a mismatch between code and requirements. It was a lack of requirements documentation. It was duct tape fixes in code rather than understanding the problem.

      While I like well defined variables, I can live with vaiable names of 'i' or 'j' or 'MyString' even it defines a float.

      -MyLongNickName

    2. Re:"a net productivity gain"..YES by davidwr · · Score: 1

      I have inherited metric craptons of code. Variable declarations and naming conventions were NEVER the problem I had. It was spaghetti code. It was unfactored code. It was a mismatch between code and requirements. It was a lack of requirements documentation. It was duct tape fixes in code rather than understanding the problem.

      Either your company's coding standards didn't prohibit crap code, or previous employees didn't adhere to the standard.

      --
      Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    3. Re:"a net productivity gain"..YES by mwvdlee · · Score: 4, Insightful

      Coding standards decide whether you should do "goto SomeLabel" or "goto someLabel"; they don't prohibit crap code.
      No standard can prohibit crap code because there will always be situations where the standard is the cause of crap code (i.e.; there are cases where using "goto" make for better code).

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    4. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      You mean people actually *PAY* programmers who are so shit at code comprehension that they can't work on code not in their indoctrinated style?!

      Fucking do me a favour.

      Reading and writing code in styles even vastly different to mine has no measurable impact on my productivity. However, a problem clearly stated and directly, concisely solved is absolutely always going to result in better productivity than the sort of shit I see being written by the sort of programmer who thinks coding style bears anything more than an aesthetic quality.

    5. Re:"a net productivity gain"..YES by LSD-OBS · · Score: 1

      (I left out the only 2 things I care about in coding style: consistency and structure. The former speaks for itself. The latter is stuff like avoiding stupidly deep indentations due to poor block / control structure)

      --
      Today's weirdness is tomorrow's reason why. -- Hunter S. Thompson
    6. Re:"a net productivity gain"..YES by DickBreath · · Score: 1

      > [citation needed]

      Okay, I'll give you an example of productivity gains. Consider the additional productivity you would gain if your coding standards required all comments to be in haiku or limerick form.

      --

      I'll see your senator, and I'll raise you two judges.
    7. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 3, Funny

      No. No fucking citation is needed. Go back under the bridge and play with yourself some more.

    8. Re:"a net productivity gain"..YES by badboy_tw2002 · · Score: 1

      It can if you have a rule that says:

      * Goto may be used to exit a function as a stand in for "finally".
      * Any other use of goto is allowed unless exceptional circumstances require it, and if so, clearly document in a comment why you need to do this.

    9. Re:"a net productivity gain"..YES by BasilBrush · · Score: 1

      Since I haven't used a goto since the 1980s, except in assembler, I'd love to see some examples.

      And I mean of actual gotos, not similar statements like break and continue.

    10. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      because when you leave\get fired\DIE, everyone can read your code and not have to interpret it, thus productivity gained.

      This is the correct answer. As a technical writer, I'm often called in to retrofit documentation to code that wasn't documented the first time, and no one can figure out why it doesn't work any more. At least if it's written consistently, you have a chance at getting it right the second time.

    11. Re:"a net productivity gain"..YES by Capt.Albatross · · Score: 1

      Either your company's coding standards didn't prohibit crap code, or previous employees didn't adhere to the standard.

      While coding standards can require code to be syntactically well-structured, they cannot make it conceptually well-structured, and that is where the biggest problems in comprehension (and more than a few bugs) have their origin. This is why the first responder's reply, 'yes, but not by much' is correct.

      I am in favor of reasonable coding standards, but I do not expect them to make much difference. They will certainly not 'prohibit bad code.'

    12. Re:"a net productivity gain"..YES by BLToday · · Score: 1

      Or you get old and come back to a project a few years later. I've seen guys spend a good chunk of time trying to read their old code since it was written by them when they were younger and less experience. Usually, they just end up rewriting it.

    13. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      exactly. Because It Can Be Trying, when_trying_to_read_several DifferentStylesAllPutInThe SAME PLACE.
      adjSome nounPeople verbFind adjOther adjPeople's nounSyntax VeRy TiRiNg To ReAd.
          Let alone
              trying to match
                  all of the different
                      styles in order
                          to not
                                      create a problem.

    14. Re:"a net productivity gain"..YES by Capt.Albatross · · Score: 2

      You mean people actually *PAY* programmers who are so shit at code comprehension that they can't work on code not in their indoctrinated style?!

      It's more like they pay people who can only produce confused and confusing code, and then think coding standards will fix the problem.

    15. Re:"a net productivity gain"..YES by s.petry · · Score: 2

      ^This^! Nothing like going into a shop where everyone was a cowboy and trying to fix what's broken. Fixes that should take minutes take days, fixes that should take days take months, and often enough things need to be completely re-created.

      Yes standards matter.

      --

      -The wise argue that there are few absolutes, the fool argues that there are no probabilities.

    16. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 2, Informative

      Since I haven't used a goto since the 1980s, except in assembler, I'd love to see some examples.

      And I mean of actual gotos, not similar statements like break and continue.

      Then you may want to look at the linux kernel sometime.

      http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=mm/vmscan.c;h=adc7e9058181eb4d38c2f22d77bd1e413d3457e7;hb=HEAD#l674

      That lovely function uses a lot of gotos for obvious reasons. Should be obvious why they use all these gotos (there are other examples in that source file)

    17. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      Error handling.
      If you have a function that allocates several bits of memory, or opens files, or aquires some other resource,
      if one of these fails, you have to release only the ones that succeeded.
      Perfect use case for goto.

      For example: every single device driver.

    18. Re:"a net productivity gain"..YES by SourceFrog · · Score: 2

      Coding standards decide whether you should do "goto SomeLabel" or "goto someLabel"; they don't prohibit crap code.

      Sure, but in my experience the two tend to go together. It's like, the type of person who holds themselves to good standards in areas of variable naming, is also the type of person who tends to hold themselves to good standards in areas like software design vs spaghetti. The type of developer who is too arrogant and lazy to follow a convention is usually too arrogant and lazy to write decent code. It's about a mindset of professionalism, a clear head, and about taking pride in your work. Some people are professionals who take pride in their work, and this usually reflects in multiple ways.

      Also, the arrogant laziness displayed by the summary poster, he doesn't feel the pain of his own laziness because it is 9 times out of 10 other people who have to clean up after him and figure out what he did. Egotistical gusto about being above it all, is usually the same egotistical gusto that creates a blind spot that doesn't notice that others are cleaning up a mess. The poster talks about "every shop he's worked in", so he's jumping jobs and doesn't see the next guys trying to read his code and scratching their heads, I'll bet money on it.

      Of course, conventions should be functional. I don't give a crap if you do "for (int i=0" or ("for ( int i = 0" for example. But there are some conventions that are simple to follow, and make a huge difference in reading code. For example, "m_" prefix means "member", "g_" means global, and no prefix means a local (stack) variable ... that saves large amounts of time not having to cross-check what is what, you can immediately see from just looking. Trust me, when you have more than just a tiny codebase and start dealing in "real" amounts of code, i.e. hundreds of thousands or millions of lines), then it helps.

      And they go together when cleaning up also. Spaghetti code is a big problem, but if you're cleaning up, then having some useful conventions makes cleaning up spaghetti easier.

      --
      My other UID is three digits.
    19. Re:"a net productivity gain"..YES by MartinG · · Score: 1

      Saying that someone can understand my code because I followed some coding standard is like saying someone can understand the rocket engine I built because I used standard sized screws to assemble it.

      --
      -- MartinG To mail me: echo kewyjlcxyzvjfxbqwh | tr bcefhjklqvwxyz .@adgimnoprstu
    20. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      breaking out of nested loops. There's other ways without using a goto, but the goto is just cleaner.

    21. Re:"a net productivity gain"..YES by PRMan · · Score: 1

      Some people hate breaks, continues and early returns as much as goto. Personally, I think they lead to more readable code.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    22. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      If you're building a finite state machine with code, the code can often be made cleaner with labels and gotos (since that's essentially what a finite state machine is).

      It's also popular in error handling in places like the Linux kernel. You can search for it there, or read this thread, with a good example down at the bottom.

      Which isn't to say you CAN'T do those things without gotos, just that often it is more readable with them.

    23. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      Breaking out of a multi-level loop without returning from the function. You didn't refactor the inner loops into other functions because then they would have required a lot a function parameters. The risk of misplacing one parameter is too great and you can't or shouldn't create a data structure to hold all the parameters (for some unknown reason).

    24. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      Goto in C++ is a great way to break out of an outer loop from an inner loop. The alternative is an ugly bool. It's also good if you need to know whether you stopped a loop due to the loop condition or due to a different condition inside the loop - the alternative is again an ugly bool that will crap up the flow of your code by merging two lines of execution that have nothing to do with each other.

    25. Re:"a net productivity gain"..YES by introp · · Score: 1

      Classic case which I run into somewhat regularly at work:

      void some_hot_interrupt_handler(struct some_message * p) {
      ..// sanity stuff
      ..switch (p->message_type) {
      ..case WHATEVER1:
      ....// code
      ....if (message isn't for us)
      ......goto noack;
      ....// code
      ..case WHATEVER2:
      ....// code
      ....if (message handled by FPGA, so bail out ASAP for speed)
      ......goto ack;
      ....// code
      ....if (message has bad timestamp, etc.)
      ......goto noack;
      ....// code
      ..case WHATEVER3:
      .... etc. for several more message types
      ..}
      ack:
      ..ack_message(p);
      noack:
      ..free_message(p);
      ..reenable_receiver();
      ..return result;
      }

      Yes, there are a lot of ways to solve the problem. The easiest is by breaking the mass up into inlined function calls that return to the common parts, but then you have to signal which common parts you want (ack/noack) and that sort of hamstrings the (or just this particular?) compiler's ability to generate code as efficient as the goto. And this thing is being called many, many thousands of times a second so even tiny bits of overhead really hurt. You could duplicate the ack/free/enable bit within the various message handler cases, etc., but the sprawl hurts you pretty badly, too, because that's code duplication (an error waiting to happen) and you shouldn't try to "fix" that macro-izing it because you have to keep the whole function in very limited fast RAM. You could use another signaling variable (do_ack, etc.) but then you have a huge nest of if/else within the handler and the compiler starts to have trouble with optimizing that, too.

      Our house rule is: do not use gotos... except for the few cases where they're the right tool for the job.

    26. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      Of course the silly example below can be rewritten using try/throw or by refactoring so that the goto can really be a return. For the most part you can usually use throw to replace goto, and a catch holding all the labels, but with some try-throw-catch constructs might benefit from a less nested structure for readability purposes...


      for (j=0;j<J_MAX;++j) {
          for (i=0;i<I_MAX;++i) {
              switch(primitives[i][j].color) {
              default: // fall through
              case NULL_COLOR: goto EndList;
              case RED: ctx.drawRedTriangle(primitives[i][j]); break;
              case GREEN: drawGreenTriangle(primitives[i][j]); break;
              case BLUE: drawBlueTriangle(primitives[i][j]); break;
              }
          }
      }
      EndList:
      primitives.CleanUp();

    27. Re:"a net productivity gain"..YES by manu0601 · · Score: 1

      It can if you have a rule that says:

      * Goto may be used to exit a function as a stand in for "finally". * Any other use of goto is allowed unless exceptional circumstances require it, and if so, clearly document in a comment why you need to do this.

      I would add the goto retry case. Of course it could be remplaced by a do ... while loop but sometimes explicitely writing down "retry" with the goto helps understand the code a bit better

    28. Re:"a net productivity gain"..YES by BasilBrush · · Score: 0

      Sounds like exceptions.

      So we're talking about using goto to get round a language deficiency.

    29. Re:"a net productivity gain"..YES by BasilBrush · · Score: 1

      Looks like exceptions.

      And the reason is because it's in a language that doesn't support them. Or possibly speed?

    30. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      There's a series of papers on lockless linked lists, by the same authors, which contain the same code. (Sadly I can't find it quickly using Google, and it's in the history of my work computer.)

      This code has to perform retries (e.g. compare-and-swap doesn't return what it should). The retries branch backwards to various points.

      The authors have written the code using structured programming constructs (while etc.) and it is unreadable. So, they've added comments which say "this now goes to point A above". That's right - they've added the clearer goto structure in comments to mitigate the harm that "goto considered harmful" dogma has caused their code.

      This is a textbook example of where goto is good, so it's a great shame I can't find it now :p

      I always use gotos for retries in lockless primitives, and often for retries elsewhere. The while loop can be used, but is not a natural fit.

      goto is also an excellent implementation for tail recursion (to self) on languages/compilers which don't support it properly. The tail call becomes a goto, so the transformation from natural style is simple.

      There is also the psuedo-assembler case where you're writing assembler, but using intrinsics in C, in which case goto is again acceptable, because you know what it compiles to. while etc. introduce unnecessary registers.

      I'd say about 0.1% of my control structures use goto.

      I think I started using goto again when I realized the people saying "don't use goto" were also saying "don't use early returns from functions", which is clearly stupid. Not using goto is good advice to the novice, but experts as always will find places where its use is appropriate.

    31. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      All of those are normal execution flow. Using exceptions is likely an abuse.

      You could use a variable ask = 1; and then do an if(ack) etc. I've done that. The goto will be faster though because it'll resolve to a simple jump instruction. Course I wouldn't put it past the compiler to optimize the ack away. Doing this 'right way' would involve a bunch of classes and inheritance at five times the code, another couple of files, and would never be fast enough.

      Sometimes the problem you are solving is 'messy' and you can either try to create some beautiful abstraction, which if looked at from a large enough distance is still messy. Or just jam all the crap in one place.

    32. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0

      Break and continue are actual gotos. The reason goto itself doesn't exist in higher languages is because the most common uses of goto have been replaced with a standartised version of it, and you don't need the actual statement itself to achieve what you need. If you're looking for valid uses of goto, they are mostly to replace higher-level features that don't exist in the language you're writing in.

      Cleanups after an error require a local goto in lower-level languages, but are achieved by either automatic memory management or try-finally statements in higher-level ones. A try-finally block is still a specific form of goto.

      Exception handling can be achieved by non-local goto in lower-level languages, which with enough support code could be made cleaner than maintaining global variables (like errno) and checking return values. Exceptions in higher-level languages behave like such non-local gotos.

      You can use goto to choose which loop you break or continue if you're nesting loops. If you've avoided nesting by using more functions that are more carefully abstracted, you might avoid nested loop sections altogether, and breaking out of the outer ones can be a simple matter of returning a value or throwing an exception.

      Loops and conditional statements were they themselves something you did with goto statements, until people found out they were the most common patterns in a language and all languages adopted them. Nevertheless, both are real, actual gotos.

    33. Re:"a net productivity gain"..YES by Anonymous Coward · · Score: 0
    34. Re:"a net productivity gain"..YES by mikael · · Score: 1

      goto and label are used as equivalents for throw/catch

      You have a number of tasks that need to be performed, that each involve allocating/resizing/deallocating memory or getting exclusive access via mutex's. If one task fails, you have to unwind/undo the other tasks. You could create a nested set of parenthesis:

      if ( PASS == setup_one() )
      {
          if ( PASS == setup_two() )
          {
              if ( PASS == setup_three() )
              {
                  complete_request();
                  return PASS;
              }
          else
              {
                  undo_three();
                  undo_two();
                  undo_one();
              }
          }
      else
          {
              undo_two();
              undo_one();
          }
      }
      else
      {
          undo_one();
      }

      return FAIL;

      Or you can have:


      if ( FAIL == setup_one() )
      {
          goto label_failone;
      }

      if ( FAIL == setup_two() )
      {
          goto label_failtwo;
      }

      if ( FAIL == setup_three() )
      {
          goto label_failthree;
      }

      complete_request();
      return PASS;

      label_failthree:
          undo_three();

      label_failtwo:
          undo_two();

      label_failone:
          undo_one();

      return FAIL;
      }

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
  3. Standards are (Usually) Good by craigminah · · Score: 2

    I doubt there's any productivity gain by the people who write in a particular style but I think corporations want things done a specific way so other people can work on code someone else developed. When standards get too restrictive they can create problems. A few decades ago when I moved from Pascal to C I wrote a program to reformat my code into a standardized format...wasn't too difficult and it allowed me to focus on the algorithms, content, and GUI rather than the style of the code itself. Seems like it'd be a good thing for corporations to have...a tool that auto reformats into a standard corporation-approved format.

    1. Re:Standards are (Usually) Good by Shimbo · · Score: 2

      I doubt there's any productivity gain by the people who write in a particular style but I think corporations want things done a specific way so other people can work on code someone else developed.

      Agreed, code is write once read many; it's a bad sign if a developer thinks their time is more important than everyone else's. Spending time in code reviews on it is clearly wasted though, when it ought to be automated. Someone will no doubt point out that Alt/beetroot soup/testicle in Emacs does the job.

    2. Re:Standards are (Usually) Good by jellomizer · · Score: 1

      Also they should be strict on abiding by these standards if they are not, then slowly formatting will follow the slope down to an unreadable level.

      I have seen code from companies without coding standards. You can tell the age of the code just by how it is formatted.
      Often with new code out of spacing or just everyones particular style everywhere with different degree of variable names it just makes it harder to read.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    3. Re:Standards are (Usually) Good by Anonymous Coward · · Score: 0

      http://www.gnu.org/software/indent/

    4. Re:Standards are (Usually) Good by Anonymous Coward · · Score: 0

      I did the same in my first job when they complained about line length few times each time it was to be different. This was last time I did that. Now I know nobody gives a fuck anyway. If I am judged by number of lines I write or features I implemented then the so called owners either look at what they get and reject unfinished, unmaintainable code or they do not give a flying fuck and then get what they deserved. Relaying on humans means you relay on them to mess things up - read Machiavelli for instructions on that. His writtings apply nicely especially to (self-organizing) teams left w/o supervision.

  4. Yes, they do by Anonymous Coward · · Score: 5, Insightful

    I find it impossible to believe that anyone has actually lost hundreds of hours in reviews due to style, unless they were purposely not following what are usually pretty simple guidelines.

    The differences between one style and another are meaningless, but the value of having a consistent style across an entire codebase is, in my experience, enormous. If everyone can read your code as though it was their own, that does in fact save hundreds of hours of time across the team.

    1. Re:Yes, they do by wisnoskij · · Score: 1

      It sounds to me like most of the lost time might of been him having to redo/reformat all his stuff because he refused to follow the guidelines and someone called him on it.

      --
      Troll is not a replacement for I disagree.
    2. Re:Yes, they do by WaffleMonster · · Score: 4, Insightful

      The differences between one style and another are meaningless, but the value of having a consistent style across an entire codebase is, in my experience, enormous. If everyone can read your code as though it was their own, that does in fact save hundreds of hours of time across the team.

      This statement reminds me of the player who having alway played red or blue team are soo fixed in thinking they become incapable of switching sides without constantly trying to kill their own teammates while everyone else has the capability to do so in a moments notice with no mental effort.

      It must be nice to only have to deal with code from yourself or your organization. We don't have that luxury. We have to work with code from external sources that will ignore us if we try and dictate style.

      In my opinion the superficial style elements mentioned in the summary only help the pedantic control freak types. You are ultimatly better off promoting a more permissive environment where the small pedantic shit is not sweated. Let everyones minds adapt to dealing with diversity and there will be no mental cost. It also makes both employee churn and reality of external code much easier to deal with in the long run. I find it also helps give an idea of who may have done what at a glance without having to sort through the RCS.

      Having conventions is still a good thing.

    3. Re:Yes, they do by Anonymous Coward · · Score: 0

      In my opinion the superficial style elements mentioned in the summary only help the pedantic control freak types.

      I disagree. Consistent indent rules make code easier to read. Being able to spot local vs static vs member variables at a glance makes code *MUCH* easier to read. As has been said having all the code you're looking at be one style (any style) makes the code easier to read. Context switches are bad enough in when programming without having to deal with them needlessly when reading code.

    4. Re:Yes, they do by Skapare · · Score: 1

      For the most part, I agree with you. Maybe it's just me, but there is one style aspect that does not follow this. AndThatIsThatISimplyCannotReadCamelCase. Well, at least not very fast. And for code, I do need to be able to read fast. I also find CamelCase harder to type. So I need more lower case and the spaces. And underline characters are sufficient as a substitute for a space in several languages.

      So if I were to take a programming job, I would need to check in advance what their style standard is.

      --
      now we need to go OSS in diesel cars
    5. Re:Yes, they do by lgw · · Score: 1

      ReadingCamelCaseIsAKeyJobSkill for ASoftwhereDeveloper. If YouHaveAnyProfessionalPride then YouMightWantToGetBetterAtIt.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    6. Re:Yes, they do by Fastolfe · · Score: 1

      In my opinion the superficial style elements mentioned in the summary only help the pedantic control freak types.

      OTOH, the superficial style elements should be the easy ones to adapt to. If you haven't learned the organization's style guide, expect a code review to be a bit painful. Ideally, that should stop once you learn to anticipate what the reviewer is likely to bitch about, and alter your coding style accordingly. If you've utterly failed to do that, resulting in painful code review after painful code review, that's a sign to me that you're incapable of working in that organization.

      There are some bits of personal flair that I don't think anyone is interested in forcing, but consistency in things like variable names does indeed help everyone else that's reading your code. If someone doesn't realize that Alice's coding style is to use trailing underscores for member fields, but Bob's style is to use a leading lower-case m, it's never going to be clear who wrote what and whether something that looks like a local variable is actually a local variable unless you know *everyone*'s personal style, and you know that none of them conflict and all of them actually signal things like this.

    7. Re:Yes, they do by gbjbaanb · · Score: 1

      All in all I find that style matters very little. So what if my colleague writes underscores between names in variables, and another uses camel case.. as long as everyone uses the same style within the file, I'm happy (actually, happier than a stupid standard that you have to refer to to keep your code from failing the automated style nazis)

      However, the parts of a standard that really do matter are the bits no-one seems to care about (when they're all arguing about the trivialities of bracket placement): project layout. Its no good having a file with a certain style of naming convention if I cannot find the flipping file that has the code I want to look at - we've all seen funny layouts with bits of file here and there, not to mention libraries or other dependencies tucked away in a sub-sub-folder, or documentation that is a text file hidden away somewhere.

      The thing that really annoys me is that 'professional' coders spend so much time arguing the toss about style that they miss the stuff that matters. Maybe its because I have a foot in the release management side of things that this matters more to me, or maybe I just like things to be neat.

      Style.. well, no-one can read your code even with a style-based standard as they will lay classes and namespaces differently, and their functions will always require investigation - so it realy doesn't save any time.A standard that says to put all your private variables at the end of the class, that might make a difference compared to say scattering them throughout the class - but who would do that, that would respond to a slap anyway.

  5. Don't forget the Terms and Acronyms by Smallpond · · Score: 4, Insightful

    Listing the meaning of every acronym, no matter how well known, that's my favorite part of document reviews.

    Coding standards save the hundreds of hours of somebody else going through your code and re-indenting it all so that you can't diff it any more.

  6. Long story short... by beelsebob · · Score: 5, Funny

    Programmer doesn't like the coding standards that someone else set, decided to whine about it on slashdot.

    Yes, having consistent code makes a difference, it lets you make more assumptions when reading code. If you can't manage to even manage to follow a simple style guide, you're probably doing all kinds of other sloppy things that are unwanted in the code.

    Man up and spend a little while getting used to it, and using it properly.

    1. Re:Long story short... by pep939 · · Score: 1

      You hit the nail on the head. Another blablablahhh story on slashdot. It's called cooperation people, you can't expect 100+ developers to efficiently work on seceral projects interchangeably without coding standards. And no, it's not the role of the text editor/IDE, it's part of the job.

    2. Re:Long story short... by Anonymous Coward · · Score: 0

      I discovered a long time ago that code which I was maintaining which was littered with spelling mistakes in the comments tended to be of lower quality than that produced by good spellers.

      Whether that applies only to my limited part of the programming universe, or generalises to the greater world, I can't say.

    3. Re:Long story short... by Anonymous Coward · · Score: 0

      I disagree. things where to put the braces (on a line alone vs end of statement), tab size, Camel vs. underscore.... to me those are all personal preferences. those who learn to use one convention, will find that be forced to write in a different one will make it hard for them to browse through their own code. I think designing and writing code is a form of art, and you wouldn't tell a painter how to to draw his strokes, or a writer to always write sentences in a well defined style.

      I think it's much more important to focus on things such as making sure that local variables are always initialized, and when they're structs they're memzeroed, that no undeclared function is ever called, etc. etc. Most (but not all) these things can be enforced through the use of static analysis tools and compiler flags.

    4. Re:Long story short... by Anonymous Coward · · Score: 1

      This this this this!!!!!!

      I can not tell you the number of times the one whining about coding standards for some reason just wants to control it.

      Knew a guy who rewrote a 2 year project just because he did not like the style I had. Funny how he ended up with the SAME program. My coding standard fit on the back of a napkin and I was pretty flexable about adding/removing things. My only rule was you change the rules you fix all the code to match and like soon. His took 4 pages single spaced and people were fearful of breaking it or listen to him bitch about how they used tabs instead of spaces on the end of a line. Funny too how my code had 1 standard and 3 people worked on it and his had 8 different styles (because he could never make up his mind about any style).

      Best complement I ever get from another coder? Your code is easy to read. The ones who 'bitch' about style always inevitably say 'where is my asprin'.

      The other one I love is "we are all professionals" which is usually code for "we dont give a damn about the group and are a bunch of cowboys".

    5. Re:Long story short... by beelsebob · · Score: 4, Informative

      I disagree. things where to put the braces (on a line alone vs end of statement), tab size, Camel vs. underscore.... to me those are all personal preferences.

      A couple of trivial examples of why this makes reading code much easier:
      The coding standard says "open braces should always appear on the following line, all control flow statements should have an associated brace." This code is now not allowed:
      if (some(really) && long(condition) || that(extends) && miles(across(the, line)) || and(pushes, the, code, to(the), right, off, the, screen)) doShit();
      doSomeStuff();

      Instead, this is needed (though some extra coding standard rules would be useful to clean it up further:
      if (some(really) && long(condition) || that(extends) && miles(across(the, line)) || and(pushes, the, code, to(the), right, off, the, screen))
      {
          doShit();
      }
      doSomeStuff();

      Now, I can scan read this code, and see that doSomeStuff() is always executed. I don't need to read the whole line just to check if some one's left something on the end of the if statement.

      Another trivial example, a coding standard might say "expressions should only contain pure values, never state changes. If you need to change state, use a statement." Now this code isn't allowed:
      someFunctionCall(blah(boo), foo, baz, bar, monkies, brains, xyz++, [self setCheese:29], unsafeLaunchMissiles());
      I now as a reader, no longer need to scan all the arguments to find out if there's a state change in there. This makes code way easier to understand.

      So yes, simple, apparently "trivial" coding rules can make an enormous difference to the readability and maintainability of code.

    6. Re:Long story short... by caywen · · Score: 1

      I agree, though "Funny" isn't quite the right mod.

      I find that usually when one whines about this kind of thing, the important things the developer should be concentrating on (e.g. how to make things more efficient, how to solve problems, how to maintain better overall code organization, etc) escapes them entirely.

      It's the same thing as that annoying C++ dude going around asking other C++ why their code isn't employing functional paradigms more - all the while the product has serious burning issues.

    7. Re:Long story short... by Anonymous Coward · · Score: 0

      I had something like this happen to me years ago - big company, huge codebase (millions of lines). They had a coding standard and my personal one was very different. I simply learned to work 'their way', while coding 'my way' for myself. At another (smaller) company my boss and I forever differed on our structuring of IF statements - became a watermark of which one of us had last worked on the code! Between 2 people who get along this can become an inside joke, with dozens of developers it can become a nightmare and a strict standard is the only way to go.

    8. Re:Long story short... by mwvdlee · · Score: 3, Insightful

      If you're whining about the details of coding standards, if probably means you aren't good enough to whine about something important.

      I've used numerous different coding standards for numerous different languages; every project and every team seems to have it's own standard. Just learn their preferences, use them and get code done. Very few coding standards are bad enough to care about. Usually a project has far more important issues to address than whether you should use PascalCase or camelCase.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    9. Re:Long story short... by Anonymous Coward · · Score: 0

      I disagree. things where to put the braces (on a line alone vs end of statement), tab size, Camel vs. underscore.... to me those are all personal preferences.

      Yes, they're personal preferences, which come second to consistency across a codebase.

      I think designing and writing code is a form of art

      Oh.

      you wouldn't tell a painter how to to draw his strokes, or a writer to always write sentences in a well defined style.

      Correct.

    10. Re:Long story short... by bws111 · · Score: 1

      you wouldn't tell a painter how to to draw his strokes, or a writer to always write sentences in a well defined style.

      You certainly would do those things if multiple people were working on something, or your 'brand' was defined in part by your style. Imagine hand-drawn animation where whoever did a particular cell could use whatever style he liked. And of course there is always stuff like The New York Times Manual of Style and Usage. I am pretty sure the NYT uses that to tell their writers exactly how to write a sentence.

      A standalone piece of art (a painting) or writing (a novel) is not going to be maintained by someone else, your code is.

    11. Re:Long story short... by Rakishi · · Score: 5, Insightful

      I think designing and writing code is a form of art, and you wouldn't tell a painter how to to draw his strokes, or a writer to always write sentences in a well defined style.

      Hahahahaha. When companies pay writers or artists to work on a shared piece they sure as hell mandate all those things.

      Do you think all the artwork in a game has consistent style by some black magic? Hell no, all the artists are told what style to adhere to and they do. Same with writing. Same when artists collaborate. Would you want to read a book that randomly switched fonts and writing styles every few paragraphs?

      If you want to do your own thing then fine but don't expect to do so on someone else's dime. They're paying you to work as part of a team, stop being a whinny immature child.

    12. Re:Long story short... by Nerdfest · · Score: 1

      This is the sort of thing that should be in a coding standard. Good variable names, keep the logic simple. Try and make the code so simple it really doesn't need inline documentation. If people start getting too picking about whitespace, bracket styles, etc, have your IDE format to a set format on commit and into your style on read. Many allow you to do this. They format code in a way that can easily be bested for readability by a person, but it's consistent. Keeping things simple and readable, and testable(!!!!) is the hard part. Code reviews help a lot.

      I find that many people have hard times with variable and method names, and these are on of the most important aspects for readability. One of my pet peeves is the habit some people have (from Microsoft, I think) of using an I prefix on interface names. If you're going to ugly up the name of a class, ugly-up the implementation names. The interface names are the ones that you see most of the time. Best of all, name the interface properly and name the implementation descriptively as well, just more specifically.

    13. Re:Long story short... by Anonymous Coward · · Score: 0

      I think designing and writing code is a form of art, and you wouldn't tell a painter how to to draw his strokes

      Yes, you would.

      http://family.go.com/video/drawing-mickey-mouse-944762-v/

    14. Re:Long story short... by Roger+Lindsjo · · Score: 2

      I think designing and writing code is a form of art, and you wouldn't tell a painter how to to draw his strokes, or a writer to always write sentences in a well defined style.

      If they work by them selves, then fine, they can use their own style. However, if they work together, such as drawing one section each of a comic strip or writing separate chapters in a book, then you want them to use the same style. It will be a bit harder on them and they will lose some of their personal style but it will be much easier for the reader. And the same goes for code, I don't really care if curly braces are on the same line or not, if the fields are at the beginning or end of the class definition, but when it varies in the same project or even the same file, then it makes reading and comprehension much harder. And most code that is used has more developer time spent on reading it than writing it.

    15. Re:Long story short... by Anonymous Coward · · Score: 0

      I don't find one more readable than the other. The only caveat would be that if the line is longer than the screen. That's a faux pas that should be avoided, but putting a one liner at the end of an if, sorry, but if you have readability issues with that, you suck at coding. Look, does the line end with a semicolon if it starts with an if, if so, then that's the whole line, not exactly rocket science, and not exactly more readable one way or the other. Plus, I like to try to keep entire functions on the screen at once, the first format aids in this, the second does not.

    16. Re:Long story short... by UnknownSoldier · · Score: 1

      I agree with your points.

      I usually replace chained-conditional logic into their own separate line so that

      a) it is easier to add more conditions
      b) each line is a separate bounding condition

      i.e. This code is too hard to figure out the number of independent conditions:

      if (some(really) && long(condition) || that(extends) && miles(across(the, line)) || and(pushes, the, code, to(the), right, off, the, screen)) doShit();

      Whereas this is easier:

      if( (some(really) && long(condition) || that(extends) && miles(across(the, line))
        || and(pushes, the, code, to(the), right, off, the, screen)
        || future_edge_case( state2) // easy to add ...
      )
      {
          doShit();
          doMoreCrap();
      }

      Of course modify the brace style to fit your indent style.

    17. Re:Long story short... by Anonymous Coward · · Score: 0

      I think designing and writing code is a form of art

      Your opinion is objectively false. Unnecessary empty space in a painting can carry deep significance. Unnecessary empty space in your code just makes it unreadable.

    18. Re:Long story short... by Anonymous Coward · · Score: 0

      not to push the metaphor too far, but when you read a book which is a collection of work from different authors, they do not have the same style.

      RE not expect to do so on someone else's dime... I'm lucky enough to work for a major networking company on a very large project. The enforced process is not perfect, but luckily having all the braces in the same place in all files is not something that is enforced. So I'm not whining at all.

      IMHO if an engineer can adapt to a style of parenthesis or number of space per tabs, then a reader of the code should be able to read in any style too. Tools to convert from one style to another have existed forever, so changing stile temporarily or permanently when code ownership has to move from an engineer to another can easily be done.

      while I can accept a company enforcing a standard, I will consider working such company only after they've demonstrated they have addressed more important aspects (such as some coding practices, enforcing testing with valgrind, etc.).

      Re being accused of being an immature child.... at my 44s, I take that as a compliment!

    19. Re:Long story short... by gbjbaanb · · Score: 1

      the only coding standard that is required there is the one that says:

      Code MUST not be written like you are a fuckwit.

      Even without a standard, I'd look at that and either gently rebuke the coder (who I hope would agree that it was bad and needed formatting - we all do stuff like this occasionally), or would just reformat it to be readable. No drama, problem solved.

      The problem with the standard is that it refuses the places where the: "if (foo) bar(); " style is appropriate - eg. times when you have a large block of repetitive code like this, where formatting it onto 2 (or 4 with bracket placement demands) would make it unreadable.

    20. Re:Long story short... by beelsebob · · Score: 1

      the only coding standard that is required there is the one that says:

      Code MUST not be written like you are a fuckwit.

      The problem is, as this very ask slashdot is pointing out... There's always someone who thinks they aren't a fuckwit, but is. It's much better to codify exactly what fuckwittery means, than to trust people to figure it out.

    21. Re:Long story short... by Anonymous Coward · · Score: 0

      Reading an anthology is like using a completely separate module which has it's own coding standard. A single narrative should have a single style.

      The writer should adapt because he's adapting 1:1 his personal style to standard. The reader would have to adapt many:1. And furthermore, nontrivial code is read far more than it is written.

      Whitespace and braces keep getting talked about but there are other style things like variable names, parameter conventions (list of bools vs enum vs bitfield of flags vs combined), goto cleanup vs. triangle coding vs macros vs. non-exceptional exceptions, object lifetime strategies (RAII? Recounting?). Don't need a strict position on all these.

    22. Re:Long story short... by Anonymous Coward · · Score: 0

      Yeah, following a coding standard isn't hard and any uniform standard greatly improves readability. Knowing when to break the standard for readability takes a bit more tallent and shouldn't be done too lightly.

    23. Re:Long story short... by chrismcb · · Score: 1

      Newspapers and other similar places that employee lots of writers, do indeed have a writing style.

    24. Re:Long story short... by gbjbaanb · · Score: 1

      fuckwittery is like obscenity - I know it when I see it.

      and when I find such a fuckwittery in practice, my tactic on resolving it depends on the quality of the fuckwit - if he's my peer, I point it out and expect him to realise it himself, if he's my junior then he gets a code review session. If he's my boss, I offer to polish the bits his greatness didn't have time to complete himself :)

    25. Re:Long story short... by Rakishi · · Score: 1

      not to push the metaphor too far, but when you read a book which is a collection of work from different authors, they do not have the same style.

      I'm not talking about an anthology, I'm talking about a book with multiple writers.

      Re being accused of being an immature child.... at my 44s, I take that as a compliment!

      I wouldn't.

    26. Re:Long story short... by Anonymous Coward · · Score: 0

      The coding standard is 84 page long in our organization...
      I would not call it "simple".
      And yes, it makes the code practically impossible to read and bug-prone.

    27. Re:Long story short... by Anonymous Coward · · Score: 0

      I have to agree with that. I'm working a lot with Linux kernel code and also a lot of code from 3rd party vendors, and it often turns out that the number of checkpatch errors in the received code speak a lot about the quality of it. The more checkpatch errors, the crappier the code. So, if developers don't care about the quite simple coding standard that should be followed when doing kernel development, they most likely don't seem to care about code quality either.
      This is a very unscientific study done by me and is in no way intended to p?ss anyone off.

    28. Re:Long story short... by Anonymous Coward · · Score: 0

      Your opinion is objectively false.

      What's the difference between false and objectively false?

  7. OpenStack by Anonymous Coward · · Score: 0

    Check out OpenStack and their infrastructure tools. For example, they have a trunk gating setup for pep8 and pyflakes for their python code, and it is all opensource and automated.

  8. Eclipse by Anonymous Coward · · Score: 0

    Just use Eclipse formatter and clean up. Configure all their rules and done.

    1. Re:Eclipse by gantzm · · Score: 2

      I don't think you know what a "coding standard" is. It's not just formatting.

      --


      Excessive forking causes un-wanted children.
    2. Re:Eclipse by DickBreath · · Score: 2

      Yes. Good. And Eclipse helps format your code as you type it.

      But . . .

      You can still have format wars, but automated and invisible, and probably inefficient for the source control system. So everyone needs to import the same formatting settings into their copy of Eclipse. Or make that file part of the project.

      There is or should be more to coding standards than mere style. How about things like making methods static if possible. Not making something public unless there is a reason. Keeping local variables within the smallest possible scope, etc.

      Some of those kinds of rules really CAN have productivity gains for other programmers who have to read and comprehend code written by someone else.

      --

      I'll see your senator, and I'll raise you two judges.
  9. Yes, it really does. by Anonymous Coward · · Score: 1

    The fact that you're even asking this question shows you've never had to deal with maintaining code which was written without regard for a consistent coding style. Deal with conforming to a coding style, and get back to us when you have a bit more experience in the real world.

  10. +1 insightful, disagree by chadenright · · Score: 1

    I lost about three days of productivity on a new programming language (the Asterisk extensions.conf stuff, actually) because it turns out that that particular language treats whitespace after a comma in a function call as part of the passed parameter. A wonderful example of a language enforcing a language standard -- you cannot put a space after your commas, or the language will break. I only wish it had been documented a little bit better. On balance, though, I would argue that that's a perfect example of a very good reason NOT to strictly enforce coding style.

    1. Re:+1 insightful, disagree by bzipitidoo · · Score: 1

      Asterisk is a mess. Weird, idiosyncratic syntax that changes from version to version, poor documentation, and a lack of capability. You can program in the stuff, but it's not easy. It's a good cure for people who hate Perl and shell scripting. After struggling with crap like Asterisk, if you don't long for something better like Perl, you aren't a programmer.

      --
      Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
    2. Re:+1 insightful, disagree by 93+Escort+Wagon · · Score: 1

      I lost about three days of productivity on a new programming language (the Asterisk extensions.conf stuff, actually) because it turns out that that particular language treats whitespace after a comma in a function call as part of the passed parameter.

      Sounds like the PHP developers have been doing a little moonlighting for that project.

      --
      #DeleteChrome
    3. Re:+1 insightful, disagree by mcgrew · · Score: 1

      I only wish it had been documented a little bit better. On balance, though, I would argue that that's a perfect example of a very good reason NOT to strictly enforce coding style.

      I would argue the opposite. Of course, that assumes the coding style fits the language; if the language prohibits spaces after a comma, the coding style should insist on it.

    4. Re:+1 insightful, disagree by DrVxD · · Score: 1

      PHP developers

      Awooga! Oxymoron alert.

      --
      Not everything that can be measured matters; Not everything that matters can be measured.
  11. It's your responsibility. by pclminion · · Score: 5, Insightful

    We live in the future, why don't our tools enforce these standards automagically?

    Some do. As the developer it's your job to make sure it happens, however you do it.

    As a result, I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms

    Was the nit picker correct? That is, was he pointing out true variances from the standard? If so, the fastest way to appease him is to cram your ego and make the changes. If you're arguing about something that is clearly spelled out in the coding standard, then YOU are the one who is wasting time by arguing about it. If not, and the nit picker is just slinging shit, then call him out for wasting time in meetings.

    1. Re:It's your responsibility. by Whatsmynickname · · Score: 1

      If so, the fastest way to appease him is to cram your ego and make the changes

      Problem is, as the OP was pointing out, is if you are spending all of your time appeasing and doing low level crap, while huge gaping holes of functionality are NOT being addressed because all of your working hours is spent appeasing everyone, your project is not going to be finished on time and the customers are not going to be happy. The term I have for this is "the process IS the product" where you're spending most of your 24hrs a day doing procedural crap instead of addressing the actual problems because you're mired in appeasing process people.

      This attitude is precisely why modern day work environments never get anything accomplished anymore and large scale projects mostly go to crap.

    2. Re:It's your responsibility. by pclminion · · Score: 1

      I'm not disputing that overbearing processes can waste a lot of time. But when a process is in place, if you attempt to subvert or struggle against the process, you are making it even less efficient than it already is. The real solution is to fix the process, but if you can't do that, there is nothing to be gained by deviating from it. Usually.

  12. Consistent Style Is Important by Anonymous Coward · · Score: 1

    Keeping a consistent style is important. If you are part of a larger project, then there needs to be a cross-project standard. I cannot say whaich practices/standards are best. You just need to have one.

    1. Re:Consistent Style Is Important by mikael · · Score: 1

      You should have some kind of "lint" program which does the coding style checking automatically. Alternatively, a "cb" (C-beautifier) which does the coding style formatting automatically. There is also "doxygen" which can create manuals out of comments placed above functions.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
  13. Some things do, but not those issues by AuMatar · · Score: 2

    Things like using solid variable/function names, providing sufficient (and quality) comments, and keeping similarity in architectural style matter. How many spaces you use (as long as you use some indentation) or what style of variable names you use makes no difference. And anyone who brings it up in a code review should be shouted down- the purpose of a code review is to find bugs, missed corner cases, unintended consequences of a change, and to find alternate ways to solve a problem. It is not there for cosmetic issues, and anyone who brings them up is wasting time for no gain and makes the code reviews of the entire organization less useful.

    --
    I still have more fans than freaks. WTF is wrong with you people?
    1. Re:Some things do, but not those issues by SourceFrog · · Score: 1

      I have a feeling the original poster is having "nits picked" on more than just cosmetic issues, and that he only mentioned 'whitespace' as the most extreme example to try paint it as if it is only cosmetic issues.

      --
      My other UID is three digits.
    2. Re:Some things do, but not those issues by Anonymous Coward · · Score: 0

      Quality tip for all the new programmers out there: If all variables in someone's code are named x1, x2, x3, x4 and so on, and you are shouted down for pointing out that this might be a problem, run (don't walk) away from the team you are working with. Nothing good can come of staying in that place.

    3. Re:Some things do, but not those issues by chrismcb · · Score: 1

      While I think a consistent standard is important. A sit down code review is NOT where you argue over the coding standard. In a peer to peer review, or when you first start and your boss/mentor reviews your code.
      If someone is noticing your code is never to the standard, then he or your boss should take you aside, OUTSIDE of the code review and mention it. OR make a simple comment in the code review and move on.
      Code Reviews aren't were you nitpick over the standard, code reviews are to make sure the code follows the spec and doesn't have bugs.
      On the other hand, if your company has a coding standard you should be following it.

  14. Entitled Aspie by Anonymous Coward · · Score: 0, Funny

    From the summary:

    " I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms. "

    Aww, baby is whining about inconvenience because baby wants to do things only baby's way even though there are guidelines and standards to follow. baby doesn't like to conform to standards other than his own, even if it means that everybody else loses hundreds of hours having to adapt to his style--which they won't, for long if baby keeps being difficult and stubborn.

    -- Ethanol-fueled

    1. Re:Entitled Aspie by Anonymous Coward · · Score: 0

      Wait, you just called every female I work with an aspie. I thought assburgers was a boy thing only?

      Think apies are bad about this thing? Try telling a female in a mostly female environment that they didn't adhere to a standard.

  15. Tools support by K.+S.+Kyosuke · · Score: 3, Informative

    We live in the future, why don't our tools enforce these standards automagically?

    man gofmt

    Of course it's a good idea. You wouldn't want to read a book printed wholly in italics, now would you? It's not that it's impossible to get used to it, only we got un-used to it and standards are useless unless you cling onto them at least for a while.

    --
    Ezekiel 23:20
  16. following standards by Anonymous Coward · · Score: 1

    If you can't code to published standards, what makes you think your algorithms are any better?

  17. Naming, sure. Whitespace? No. by TheNinjaroach · · Score: 5, Insightful

    Consistent naming is important. It lets you quickly call into libraries that other people have written without having to double check, "was that camel cased or underscored spaced?"

    But nit-picking over whitespace is simply annoying. Any person who insists on that much compliance might be trying to compensate for lack of performance in more important areas.

    --
    I went to eat some animal crackers and the box said, "Do not eat if seal is broken." I opened the box and sure enough..
    1. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 0

      maybe, but it's not THAT hard to get right, you just run the code through the style checker, and have it correct errors.

      You DO have an automated style-checker, right?

    2. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 2, Insightful

      You are wrong. Everyone on the team is using spaces, then OP starts using tabs. The tabs look fine in his IDE so he doesn't care, then someone tries to use vim for a quickly check/change something and indentation is screwed up everywhere OP made an edit.

    3. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 1

      But nit-picking over whitespace is simply annoying.
       
      I
       
      hear

      you, borther
       
      .
       
      These whitespace rules in english are also very
       
      Annoying
       
      .

    4. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 0

      Internal whitespace can be nit-picky, but indentation at the left margin makes a huge difference for readability. (Of course, if you're working in Python, it's proper syntax to start with.)

      I've just spent the last two weeks dealing with a PL/SQL procedure I've never worked on before, full of nested sub-procedures, none of it adequately documented or commented. The indentation was as chaotic as a seismograph during a small earthquake. I didn't have time to refactor anything, but I did take the time to fix the indentation so block scopes would be clearer. It is far easier to find the matching END; on a procedure 3 levels deep when everything within the loop block is properly indented.

    5. Re:Naming, sure. Whitespace? No. by confusednoise · · Score: 1

      Disagree, at least for whitespace with operators. Compare:

      variable=value+other*another

      with:

      variable = value + other * another

      To me, the second is worlds more readable and worth enforcing in a coding standard. From there, I'd probably agree with you that anyone who pays too much attention is wasting their time on trivial stuff, but this one's worth it. I remember clearly having my first code review years ago and got dinged for the above - I was mad then, but not much later realized the reviewer was right.

    6. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 0

      idontknowwhyineedtousespaces.itseemsprettyredunantgiventhaticanunderstandwhatihavewritten.areyouretarded?

    7. Re:Naming, sure. Whitespace? No. by Nerdfest · · Score: 1

      If the language supports it, I find:

      variable =value
                +(other*another)
      ... but with the '=' and the '+' aligned vertically properly. In general, I find where you don't need a space, don't use one. If you need white space to make it more readable, use a new line or tabs instead. Personal preference of course, but I find all the spaces just spreads the content out, where what you really want is is organized better visually, not just spaced out more.

    8. Re:Naming, sure. Whitespace? No. by casings · · Score: 1

      Then how about you standardize the IDE?

    9. Re:Naming, sure. Whitespace? No. by RabidReindeer · · Score: 1

      But nit-picking over whitespace is simply annoying. Any person who insists on that much compliance might be trying to compensate for lack of performance in more important areas.

      Or they could be of an autistic persuasion. Which means that such apparently minor things are major irritants to them.

      Not, of course, that anyone would expect to find ASD people gravitating towards software development. Much.

    10. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 0

      That's already done -- by asking "what's your favorite editor?"
      If the candidate answers wrong, he doesn't get hired.

      (* The only correct answer to the editor question is to indicate willingness to adapt to coding standards.)

    11. Re:Naming, sure. Whitespace? No. by allo · · Score: 1

      thats bullshit.
      Everyone should use the IDE, he can use the fastest, not the one some manager decided on.

    12. Re:Naming, sure. Whitespace? No. by Anonymous Coward · · Score: 0

      ...and everyone should be using tabs. duh.

  18. If not, why do we have them? by mcgrew · · Score: 1

    It's like reading slashdot. You come across someone who can barely spell, has trouble with homophones, puts extraneous apostrophes in, and it makes it much harder to read for someone who is used to reading. The same goes for coding. If the reviewer sees a bracket where he expects a curly brace, even though the two are interchangable, it's going to slow him down.

    Plus, if you used three spaces instead of a tab, what other errors are in your code?

  19. IDE's can enforce these standards by Anonymous Coward · · Score: 0

    At least eclipse has some xml files. Also checkstyle exists.

  20. What IDE are you using? by decipher_saint · · Score: 2

    I ask because in the last 5 years I've been using various flavours of Eclipse and Visual Studio and both of them come with document formatting features that you can template.

    The only thing I ask people if they plan on formatting a document during a change is to do it either before or after their change so I can review the differences more easily in source control revision history.

    Oh and to answer the question, yes, I've found if the team can adhere to vaguely common style they can navigate their way through our entire codebase without getting lost in one individual's style preference.

    Obviously YMMV in this regard.

    --
    crazy dynamite monkey
  21. Is it meaningful to measure seconds. by will_die · · Score: 1

    Ok you may spent an hour or more setting up the code beautifier with the rules but after that what does it take a min or so at most to be run?

  22. reading by Anonymous Coward · · Score: 0

    working with a bunch of developers who all have very different coding styles, its much much easier to read code when it is all in the same format.
    I would imagine this is especially true for management that may have some coding background, but aren't hardcore devs.

  23. It's about conformity, not code by crazyjj · · Score: 1, Insightful

    It's a test on following orders and attention to detail. We don't need any of you rogue coders 'round here, see?

    --
    What political party do you join when you don't like Bible-thumpers *or* hippies?
  24. Obfuscation by Script by lowsix · · Score: 1

    I'll bet we could fairly easily construct a perl/awk/python script that will convert between the two, assuming one isn't already in standard use. Sounds like a waste of time to worry about it to me.

  25. PSR by diemuzi · · Score: 1

    Coding standards makes quite a bit of difference. If I'm going to review the code you've supplied me with I'd better be able to clearly read and understand what you are doing. I'm a big believer / follower in the FIG PSR rules to follow.

  26. Coding standards simplify by Anonymous Coward · · Score: 0

    Coding standards give useful hints as what the other person is trying to do. Yes it can get very silly but when you are tired and working on a tight deadline to fix a critical bug in someone else's code every little bit helps.

  27. Write a pretty print! by jackb_guppy · · Score: 3, Insightful

    With such poor standards as white space and curly braces, write a pretty routine to clean it up. One to convert to your standard and one to convert back to theirs.

    I come for the world of 6 upper charter names names for fields/columns. There naming conventions mean something becuase every is abbrivated. We keep or stnadards on single sheet of paper to so that could be followed.

    Now get of my lawn!

    1. Re:Write a pretty print! by trg83 · · Score: 1

      If you do that, just make sure your algorithm really is the proper inverse function. I've been caught by this one time when it wasn't clear what the standard line-wrapping rules were. I still managed to change the code and cause diff problems for everyone else on the team. Now, I just go with the flow and practice "chameleon coding". YMMV.

    2. Re:Write a pretty print! by Anonymous Coward · · Score: 0

      I HATE COBOL!

    3. Re:Write a pretty print! by BasilBrush · · Score: 1

      With such poor standards as white space and curly braces, write a pretty routine to clean it up. One to convert to your standard and one to convert back to theirs.

      I come for the world of 6 upper charter names names for fields/columns. There naming conventions mean something becuase every is abbrivated. We keep or stnadards on single sheet of paper to so that could be followed.

      Whoops! You forgot to run the pretty routine to convert your standard back to English.

    4. Re:Write a pretty print! by narcc · · Score: 1

      With such poor standards as white space and curly braces, write a pretty routine to clean it up.

      Even better, you should need to do less than that. Don't most IDE's and even code editors include a pretty printer these days? Did everyone forget about them?

      I get having rules about naming using camelCase, underscored_names, and OtherStyles -- They can even be mixed as a handy way to provide more information -- like Hungarian notation but easy to read.

      Whitespace and rules about braces don't make any sense . That's a solved problem. Pick a style for source control to reformat to on check-in and configure your editor to reformat it the way you like when you're working. At worst, you'll have a week or two of hell forcing this on an existing project but for new projects it's no problem at all.

      Where do braces go?
      http://c2.com/cgi/wiki?WhereDoTheBracesGo
      http://blogs.msdn.com/b/peterwie/archive/2008/02/04/pedantic-coder-where-do-braces-go.aspx

      Flame on!

  28. Stop whinging by Anonymous Coward · · Score: 0

    Stop whinging and do your job properly, so whoever comes in after you can get on with their job and won't feel the need to post your shithouse code to http://thedailywtf.com/

  29. Yes, but impractical for humans to enforce ... by JSkills · · Score: 1
    Rather than attempt to get various teams of developers to code in one exact style, we decided on implementing a single standard for coding but to automatically enforce it via a pre-commit hook when someone checks in their code into our repository. That way, managers don't have to waste their breath attempting to micromanage the minutia of where the semi-colons go, developers can be free to work how they're most comfortable, and when you check code out you can always expect it to be in the exact same familiar form.

    This seems to have given us the ability to benefit from a single coding standard for what's in our code base, while *not* spending any developer or manager time to have to worry about it getting/keeping it that way ...

  30. coding style can get you fired by TheGratefulNet · · Score: 3, Informative

    happened to me. at a large networking company (I don't want to mention the name, for various reasons) I felt more comfortable with my own coding/indenting style, which included lots of whitespace (my eyes are old and the extra vertical WS helps isolate 'paragraphs' from each other and that clustering really helps me a lot).

    my boss felt so strongly about it, though, that he'd constantly use that as a way of beating me up. eventually, I got fired and I think our conflict was a major part of that.

    I have been coding for over 35 years (in C, mostly) and I have a damned good handle on how to code for readability and supportability. but when it comes to styles, the guy in charge wins, no matter what, even if there is no right answer, per se.

    you should not code in a radically different way from the existing codebase, but to complain about line length (at the time, they were HARSH about keeping lines to 80chars max, which was so braindead) and my vertical whitespace just really ticked one or two people off enough that they complained and got me canned.

    so, yes, those that want to pick fights, will do so over stupid little things and make a big damned deal about it, too. part of 'coding politics' I guess. large and small companies all have this problem and it won't ever go away.

    better companies can be flexible. the more rigid ones, I find, have lost their way. writing code is not a mechanical thing; there's an art to it and to strip all individualism from the task is just plain wrong, to me.

    --

    --
    "It is now safe to switch off your computer."
    1. Re:coding style can get you fired by Mr.+Slippery · · Score: 1

      but to complain about line length (at the time, they were HARSH about keeping lines to 80chars max, which was so braindead)

      Making me resize my editor window to deal with your code is braindead^H^H^H^H^H^H^H^H^Hannoying. Code wider than 80 columns also doesn't print well by default.

      Use an indent you want, use any variable names you want, but for fsck's sake, 80 columns unless you've occasionally got a really good reason (code that writes code, for example) to break it. And comment, dammit, comment.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    2. Re:coding style can get you fired by dcollins · · Score: 1

      Hell, I'd consider firing you for being unable to use conventional English capitalization. My eyes are now crossed.

      --
      We know where leadership by an anti-intellectual "strongman" who scapegoats minorities and likes boisterous rallies goes
    3. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      at the time, they were HARSH about keeping lines to 80chars max, which was so braindead

      I work at Google. We have an 80 char rule, and it is absolutely NOT brain-dead. I want to have my editor configured to a certain width so that every file in the code-base will be readable in it. Now, if the code base were to be rewritten today from scratch, I'm sure 80 would be replaced with 100 or some other number, but it's not. It's 80. And a consistent 80 is a hell of a lot better than inconsistency.

      Wherever you were, you shouldn't be fired for violating that rule, but if you can't see why it has value, I can see a deeper problem.

    4. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      80 chars max sounds like a very sensible approach. Okay, maybe 90-120 may be more readable to YOU, while you're coding, however.
      After 3 months, or reading someone else's code, 80 chars is a good target.

      Enforcing 80 instead of 90, or bitching about it, sounds like an approach to get rid of you however.

      I just don't get it. If there's a problem. Why not just pretty-print it and be done with it? Whitespace is not important to the FUNCTION of the code at all!

    5. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      This is not "politics." You got fired for insubordination. The details don't really matter. Constantly not doing doing what the boss tells you will get you fired pretty much anywhere.

    6. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      I am also facing a similar situation. Missing a few extra white space here or there could create a bigger problem than getting the logic completely wrong.

      Improving readability is one good benefit of following a coding standard. But there were many instances in my career where people who does not even know how to read code used minor coding standard violations to torture me.

    7. Re:coding style can get you fired by PRMan · · Score: 1

      I code in a proportional font. Fixed fonts are so 80s.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    8. Re:coding style can get you fired by OhPlz · · Score: 1

      You're either commenting from the 1900s or you're that one guy that rotates his widescreen monitors to be vertical rather than horizontal. I'm leaning to the former given the printer comment. How often does anyone print code anymore? The only times I can think of are either sample code to give to interviewing candidates or the rare occasion of trying to reverse engineer a tricky code shit ball.

      The only issue I have is with code diff utilities that don't work well with multi-monitor setups. They need an option to treat "maximize" as a request to maximize across two monitors. Trying to review code on someone's machine that isn't setup for two displays can be quite cringe-worthy. Especially considering that nearly everyone in our engineering org has at least three displays on their desk.

    9. Re:coding style can get you fired by TheGratefulNet · · Score: 1

      caps are optional. you got the message, didn't you?

      caps hurt (think: carpal tunnel).

      at 20 or 30, it didn't hurt. I'm 50 now and let me just say, every little bit that helps is appreciated. less hitting of caps key, the better.

      sorry it offends you.

      --

      --
      "It is now safe to switch off your computer."
    10. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      You might believe you got fired for whitespace and code formatting, but you did NOT get fired for code formatting. Even if that's what they told you.

    11. Re:coding style can get you fired by TheGratefulNet · · Score: 1

      we've had xterms (and similar) for well over 20 years now. the wyse vt220-alike went out decades ago.

      to stick to 80-cols in today's world really makes no sense.

      when I write an if-statement, sometimes the full logical line is longer than 80 but I want to keep it as one physical line. over the years, this style has helped me and I prefer to keep that if I can. breaking a physical line (that holds a concept) into multiples just because of some 'maybe someone will print it' reason is not strong enough of a reason. I'd like my eye to see that line and acknowledge it and not have to follow down a few more lines just for word-wrap prettiness.

      --

      --
      "It is now safe to switch off your computer."
    12. Re:coding style can get you fired by csumpi · · Score: 1

      "And comment, dammit, comment."

      Nothing like code that's been updated a hundred times with comments from a year ago. How about just write readable code?

    13. Re:coding style can get you fired by Kjella · · Score: 1

      caps are optional. you got the message, didn't you? caps hurt (think: carpal tunnel). at 20 or 30, it didn't hurt. I'm 50 now and let me just say, every little bit that helps is appreciated. less hitting of caps key, the better. sorry it offends you.

      If the code standard involved CamelCase I think the jigsaw puzzle just fell into place.

      --
      Live today, because you never know what tomorrow brings
    14. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      I'm afraid I'm siding with your boss.

      It's not about you alone. It's about others having to edit your code too. Most people configure their editor to adhere to the coding rules. It's incredibly annoying to open a file of somebody else and find a piece of code that breaks the rules everybody else follows.

      There are plenty of ways to make programming an artistic activity. Not following very basic consistency rules when working in a team is not one of them.

    15. Re:coding style can get you fired by TheGratefulNet · · Score: 1

      lol. no, it was not about case issues. I know one guy (just one guy, but that's all it takes, sometimes) was mad about whitespace, specifically. he made a big deal about it, as I recall.

      go figure.

      --

      --
      "It is now safe to switch off your computer."
    16. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      Honestly, if the problem really was WS and line length or any other cosmetic style point then getting fired over this is on you. It is very easy to run c code through code formatters and switch it back and forth between any styles. Any code really but especially c, it has been around forever and there are tons of shell scripts to handle this. I have known several programmers who ran their own personal code prettifiers just for this reason.

    17. Re:coding style can get you fired by Salamander · · Score: 3, Informative

      The only issue I have is with code diff utilities that don't work well with multi-monitor setups.

      You should try to appreciate that not everyone shares your circumstance. Sometimes the most senior developers on a project might have to review code while on the road, e.g. visiting customers or presenting at conferences. Not too many laptops have multiple monitors, and you wouldn't want to carry one if it did. Some of the very latest have pretty decent resolution, but they cost a lot more and they have a very fine dot pitch so the number of characters doesn't scale up as much as the number of pixels. Under those circumstances, code that doesn't display well in a *side by side* diff on a single small-ish monitor is a more serious issue than the junior developer's fetish for super-long lines. Eighty columns might not be the absolute best width, but it's in the range that makes such diffs under such circumstances productive, and it's a width that a lot of people (and tools developed over the last few decades) can handle reliably.

      Also, people who study reading have known for half a century that long lines are hard to scan accurately without a saccade leaving the reader's eyes on the previous or next line, which means that they're bad for readability even on wide monitors. There's a reason newspapers used to set type in columns instead of all the way across the page. You'll need a much better reason than personal aesthetics to do something that's bad for readability and a pain for other members of your team. Without such a reason - and I haven't seen any, anywhere in this thread - that's just selfish and immature.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    18. Re:coding style can get you fired by OhPlz · · Score: 1

      Sometimes the most senior developers on a project might have to review code while on the road, e.g. visiting customers or presenting at conferences.

      Agree to disagree, but that is not a significant enough concern to base a standard on. If one developer is that critical within your organization, you've got bigger issues than source code line width.

      Also, people who study reading have known for half a century that long lines are hard to scan accurately without a saccade leaving the reader's eyes on the previous or next line, which means that they're bad for readability even on wide monitors. [..] You'll need a much better reason than personal aesthetics to do something that's bad for readability and a pain for other members of your team.

      I'm not suggesting that every line needs to be 320 characters wide. What I am suggesting is that there's no need to force a strict this-number-of-characters policy. Developers know what works best.

      I can easily counter your traveling coder example. Think of the majority of developers that are sitting in an office environment. You're most likely talking one or more widescreen LCDs. A narrow width coding standard is going to punish them by forcing them to scroll vertically while seeing a good chunk of their display real estate go unused. You could argue that rotating the monitor to be vertical is a solution, but many are going to find that too unnatural.

      Perhaps IDEs should support a multi-column view similar to newspapers. Personally, I don't see an issue with wide code. If I can't follow the text, I can arrow up or down to have the IDE alter the background color of that row for easier reading. Many diff tools have the same feature. We tend to favor smaller functions, so that too is going to help your eyes follow along. If a block of code is just too painful, someone can and will break it into two or more. No standard required.

      selfish and immature

      That's generally how I feel about contrived coding standards. I've seen this kind of thing kill code reviews. Instead of looking for logic problems or design flaws, you'll get that one guy being anal retentive about line width or ratio of one thing to something else. That kind of distraction doesn't generally serve the best interests of the organization. I'm not saying we should all be code-cowboys, but I think a team should treat themselves as professionals and deal with issues like this only if there's a serious need. Even then, just sitting down with the person responsible and explaining it should be sufficient.

    19. Re:coding style can get you fired by Salamander · · Score: 1

      If one developer is that critical within your organization, you've got bigger issues than source code line width.

      On most projects, there will be parts of the code that few understand. Yes, if that number is zero or one you have bigger problems, but trying to get it beyond two or three for every single piece is infeasible. Given how mobile people tend to be nowadays, and how variable their working hours across different time zones might be, it's quite common that the only reviewer available at a time of need (e.g. fixing a customer's problem in production) might be in a constrained environment. I guess it's not a problem if all you want is rubber-stamp reviews of simple code, but otherwise it's something you have to consider.

      Think of the majority of developers that are sitting in an office environment.

      Um, no. Having all of your developers in a single office all the time is increasingly uncommon, especially on open-source projects. Even fairly stodgy companies often have remote workers nowadays, all the way down to cutting-edge startups where practically nobody lives in the same city. Assuming such a majority is a bad basis for deciding policy.

      I've seen this kind of thing kill code reviews. Instead of looking for logic problems or design flaws, you'll get that one guy being anal retentive about line width or ratio of one thing to something else.

      Yes, I hate that kind of review myself, and I'll bet I've been subjected to about a dozen times more of them than you. However, conforming to a line-length limit is comparatively easy. Required scaffolding and forbidden constructs, function-length and even variable-naming conventions can all be much more of a pain. Part of teams being professional is respecting your colleagues and putting needs before whims. If you can't do that, or if staying within a length limit is so hard for you, then - to borrow your phrase - you have bigger problems.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    20. Re:coding style can get you fired by OhPlz · · Score: 1

      Having all of your developers in a single office all the time is increasingly uncommon, especially on open-source projects. Even fairly stodgy companies often have remote workers nowadays, all the way down to cutting-edge startups where practically nobody lives in the same city.

      Even if they're not all in the same offices, chances are they're in some sort of office, even if it's a home office (home as in where you live). I've known very few software developers that do their development work primarily on a laptop, and none who did so without having a docking station setup with additional hardware. It sounds like we live in different parts of the coding universe. Not surprising considering how many different types of industries need software.

      However, conforming to a line-length limit is comparatively easy. Required scaffolding and forbidden constructs, function-length and even variable-naming conventions can all be much more of a pain.

      Yep. But I don't need a business equivalent of a AD&D rulebook to throw at my peers. A simple "dude, knock it off with the acronyms already" or "if you used RAII there, you wouldn't need all this other code". Frankly, at the rate languages, platforms, frameworks, and techniques are changing, any sort of coding commandments are probably going to get outdated rather quickly. Unless it is just vapidly simple things like line width and noMoreCamelCasePlease.

      Part of teams being professional is respecting your colleagues and putting needs before whims. If you can't do that, or if staying within a length limit is so hard for you, then - to borrow your phrase - you have bigger problems.

      Respect is earned. Part of that is knowing what your team's strengths and weaknesses are. If they don't need to be harassed about trivial shit, then they shouldn't be harassed about trivial shit. It's bad for morale if people feel like they're all treated like interns. To me, issues like this should be handled informally between peers. That gives them ownership of it, and they're best suited to agree to a solution rather than be forced into one. If they can't work as peers in that way, then the team is probably doomed to failure when it comes to the bigger stuff.

    21. Re:coding style can get you fired by Anonymous Coward · · Score: 0

      happened to me. at a large networking company (I don't want to mention the name, for various reasons) I felt more comfortable with my own coding/indenting style, which included lots of whitespace (my eyes are old and the extra vertical WS helps isolate 'paragraphs' from each other and that clustering really helps me a lot).

      my boss felt so strongly about it, though, that he'd constantly use that as a way of beating me up. eventually, I got fired and I think our conflict was a major part of that.

      I have been coding for over 35 years (in C, mostly) and I have a damned good handle on how to code for readability and supportability. but when it comes to styles, the guy in charge wins, no matter what, even if there is no right answer, per se.

      you should not code in a radically different way from the existing codebase, but to complain about line length (at the time, they were HARSH about keeping lines to 80chars max, which was so braindead) and my vertical whitespace just really ticked one or two people off enough that they complained and got me canned.

      so, yes, those that want to pick fights, will do so over stupid little things and make a big damned deal about it, too. part of 'coding politics' I guess. large and small companies all have this problem and it won't ever go away.

      better companies can be flexible. the more rigid ones, I find, have lost their way. writing code is not a mechanical thing; there's an art to it and to strip all individualism from the task is just plain wrong, to me.

      Maybe they fired you for not using proper capitalization at the beginning of sentences? Your special writing style made it noticeable harder for me to read your comment, because successive sentences get merged visually, due to the visual clue of capitalization missing.

      Subjectively your comment was 20-30% harder to read to me. Annoying the readers of your code like that is stupid and asocial.

  31. Good ol indent by Anonymous Coward · · Score: 0

    For my C projects, I love "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
    Makes any C code instantly readable to me :)

  32. Most Java shops I've worked automate code style by neiras · · Score: 5, Informative

    We have always had standardized checkstyle and jtidy rules as part of our build system. We have eclipse formatting configuration that everyone uses as well. Commits don't happen unless checkstyle is happy.

    I thought everyone did this. I guess tooling is less developed in some languages, but it's not too hard to put this kind of thing into practice with a little bit of effort and buy-in.

    1. Re:Most Java shops I've worked automate code style by Anonymous Coward · · Score: 0

      Buy-in is the biggest part of the problem with some people; oh, and the previous manager decided he wanted to make all the devs happy by letting them use whatever tools they wanted, and we ended up with five different IDEs which each have their own ideas about auto-formatting.

    2. Re:Most Java shops I've worked automate code style by blackcoot · · Score: 2

      We do this in C++ and Python for all our projects now. All in the repo commit hooks.

    3. Re:Most Java shops I've worked automate code style by Anonymous Coward · · Score: 0

      I often find decompiled java code easier to read, there are not so many lies in it.

      Using the eclipse formatting with some basic instructions of how to name variables/methods is the way to go. Don't get upset about names, you're probably using your energy in the wrong way. Part of java is understanding how to name things so it becomes java, if something is badly named, then that person has not gone as far as you in his/her development in the language, tell them and move on.

      Having code fights, why bother, there are so much more to do, if someone wants to clean your code, let them. If you want to correct someone else code, please feel free to be a cleaner.

      Java was just an example, Golang is even better, there the style is in the language.

    4. Re:Most Java shops I've worked automate code style by bk2204 · · Score: 1

      We're a Perl shop, and we also use automated tools (perltidy and soon, perlcritic) before committing. It's just easier if everybody uses the same tool to do the formatting and it's automatic. When you have to remember to do the style by hand, it's easy to forget.

    5. Re:Most Java shops I've worked automate code style by ritchman · · Score: 1

      Here the company still uses CVS, plus auto-formatting should not affect legacy codebase.

      Our solution: upon commit, a simple perl CVS wrapper script calls uncrustify for all files that carry a special tag.

  33. Coding standards matter and are trivial to fix by Purpendicular · · Score: 1

    Code Complete by Steve McConnell discusses this. It is not your code, it is the company's code, the team's code. Some poor bastard will need to read this code five years from now. All you need to do is to use for example astyle or uncrustify to automatically format all code, before it is even accepted for a code review. Correctly formatted code, by a computer, should be a prerequisite. If the code is not correctly formatted, call of the inspection/review and meet again at some other date.

  34. IDEs by Githaron · · Score: 1

    Most IDEs have the ability to auto-format existing code. They also let you change the formatting rules if you prefer something different than the default. Your organization can just share formatting rules file. Code the way you want then hit the hot key before committing.

    1. Re:IDEs by TheGratefulNet · · Score: 1

      add the right emacs extensions, enable the mode and run indent all you want.

      been using c++-mode on emacs as my indenter for, well, decades, now. it does the job and its always there (emacs is never far away. right? right??).

      so, we don't have to argue about indent style, at least.

      but we surely have not settled the emacs vs non-emacs debates. that is what we should really be talking about.

      --

      --
      "It is now safe to switch off your computer."
  35. Yes for Large or Multi-Dev Projects by detain · · Score: 1

    When you have many people working on the same code base coding standards are very important. Its impossible to keep every line of code fresh in your memory so when viewing your code or someone else's, quickly identifying what each part of the code does is very important. Knowing even something as simple as a standard variable naming convention used in a program can make the difference between jumping into a block of code and accurately modifying it or butchering it.

    --
    http://interserver.net/
  36. Fix your tools by Anonymous Coward · · Score: 0

    What's wrong with your toolchain that it isn't dealing with most of this?

    Your editor should be indenting properly and doing the right thing with tabs-versus-spaces. If it isn't, poke around in the config properties until it is, or get a copy of emacs, which I guarantee can be customized to do whatever crazy thing your company demands.

    pylint (if you use python), or whatever the corresponding tool is in your language-of-choice, should be easily configurable to whine about errors like "this function is more than two hundred lines long, you should break it into smaller pieces", or "line contains over 150 characters, should be wrapped", or whatever. I've seen similar tools for c, java, etc.

    Nearly every coding style guideline I've seen except camelCase versus underscored_names should be entirely catchable by an automated tool; it should be run as part of your compile process (or unit test process or whatever), so these bugs should never be getting as far as the human pedant in your code review. And variable/function names being in camelCase or whatever should be second nature to you after a week on the job.

    If your toolchain can't deal, talk to your manager until you can shake free a few days to write an automated tool to add to your toolchain! Your coworkers will thank you, you'll get some experience with scripting...

  37. Set up 'indent' or other auto-indenter by Anonymous Coward · · Score: 0

    In my last job, they passed out a file so that Eclipse would automatically set up the company default indentation (and most other features.) Easy.

    There's plenty of code beautifiers out there.Just pick one.

  38. Cries from a sloppy coder by Anonymous Coward · · Score: 0

    If the comments on the review begin with coding style chances are that you haven't read the patch well enough yourself, otherwise you would have spotted them (and subsequently other possible problems) yourself. It's a sign of a tidy programmer, someone who attends to detail, and as such, it's an excellent self-review of your patch before handing it over to others. On the other hand, it's really something your editor should handle for you, if it doesn't you need to become better friends with it or change to something more powerful.

  39. I use Eclipse and CheckStyle by Anonymous Coward · · Score: 0

    Yes, they're important. Code styles are as different as handwriting. One person may write with all capital letters, another may use capitals and lower case, someone else may use cursive, another may use a mix of cursive for some letters and print for others. Now imagine having a handwritten book with five different writing styles all mixed up. It makes is far more arduous to read than if you had one consistent style. The key here isn't WHICH style is used. It's that ONE style is used, all the time.

    It sounds like your problem isn't that code style fascists are picking on you. It's that you don't use any tools to automatically format your code for you in such a way that everyone on your team has the same style. Our department has specific code style definition files which are used by Eclipse and Maven. These ensure that the style is consistent, and we don't commit a 50-line code update when only one line was a code change, and 49 lines were formatting junk. Having everyone use the same style definition files is important. You don't want your commit log to be cluttered with formatting junk. That makes it nearly impossible to use SVN logs and 'blame' to determine when a piece of code was changed, and why, so you can avoid fixing one bug in a way that creates five more.

  40. It spares me from headaches by Kergan · · Score: 1

    Grammars and spelling came about in the 16th century or so, for much the same reason. Yud probbabli minde iff I rote anglich zis wai bekoz youd spend wai tu moch tim vonderrin wat I rote. If you think I'm exaggerating, try reading old English manuscripts -- or worse, old French manuscripts.

    Embrace the coding standard, and enforce it for the next guy's sanity when it comes to maintenance. Ideally, setup pre-commit filters on your repo: if the code doesn't conform to the in-house standard, the repo should reject it; period, end of story. That way, nobody wastes time on it except those who aren't respecting them in the first place.

    Another already suggested that nothing beats clear thinking. I agree, but don't dismiss how consistency in code formatting improves code readability and maintainability.

  41. conFORmITY leaDS to BetTER READaBiLITY by realStrategos · · Score: 1

    Conformity makes things easier to read; It depends on how extreme the grammer nazis go. The question is how much does it really matter that i used lowercase i's or incorrectly used a semicolon ... it depends on the context.

    --
    They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
    1. Re:conFORmITY leaDS to BetTER READaBiLITY by Anonymous Coward · · Score: 0

      Unless you're referring to the extracurricular activities of the actor who plays Frasier Crane, I believe you mean *Grammar Nazi*.

      Sincerely,

      - Someone who fashions themselves more of a Grammar Marxist

  42. My thoughts by Synerg1y · · Score: 1

    I think it's not so much to encourage good practice and ensure standards, as it is to discourage bad practices that are very hard to standardize later. In fact, in newer versions of Visual Studio, when you rename a variable, it gives you the option to rename everywhere else the variable is referenced. That feature probably originated out of these standards. I don't care if you name your variable studentScore, studentscore, or StudentScore, but if you name it StudentS, ss, Sscore, please die, thanks.

  43. Simple answer: it depends! by aglider · · Score: 1

    It depends on what else is going to be put on the table.
    A uniform, ubiquitous, documented coding standard can be of great help.
    But it's still just a help or a tool, not a solution.
    You still need to know how to effectively program, you have to get a fairly good knowledge about the underlying system, the environment and, of course, the problem the program is meant to solve.
    I would say it's just like following a precise order in company bookkeeping.
    It helps a lot, but you still need to follow the rules and the law.

    --
    Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
  44. Standards are good, by Nuitari+The+Wiz · · Score: 2

    That's why everyone has their own...

    There are some standards / practices that are very important when it comes to making secure code. They avoid basic mistakes and so on. There should also be some minimal enforcement in terms of how to indent which always help to reread the code. Peer review for anything complex is also a good practice.

    As for camel case, or hungarian notation, I feel that they are mainly a waste of time in the best of case. Being pedantic about code isn't going to help anyone or any project, in fact it might make a lot of talented people leave the company.

    1. Re:Standards are good, by lgw · · Score: 1

      No one talented will be too upset about the chose variable naming convention. Mediocre self-important whiners, on the other hand, may get quite worked up over it.

      --
      Socialism: a lie told by totalitarians and believed by fools.
  45. Yes, it matters by Anonymous Coward · · Score: 0

    As someone who has come into a variety of long-standing projects and found the developers who worked before me did not have a set coding style I can definitely tell you it matters. It doesn't really matter which coding style the developers standardize on, but it matters that you have one. it is a pain switching between different styles, different approaches to comments, different naming conventions, tabs vs spaces.

    Once I remember surprising a manager who had originally hinted that I was the second developer on a project when I told her I knew I was, in fact, the forth to work on the project. When asked how I knew I pointed out there were three existing distinctive code styles scattered through the code and none of them really meshed elegantly.

    Think of it this way, would you want to read a book/document that was hand written in three different styles? Especially if the lines alternated? It would be hard to get into the flow. The same applies for programming code.

  46. Ya to me sounds like "I'm special" syndrome by Sycraft-fu · · Score: 5, Insightful

    This guy thinks he's the shit programming wise and thus has to do his own thing. He's too good to be bound by the rules of everyone else. So he keeps fucking up and then crying about it.

    His company should just can him.

    1. Re:Ya to me sounds like "I'm special" syndrome by postbigbang · · Score: 4, Insightful

      Wanting to be exempt from standards because you're "special" is a sign of immaturity. He may not need to be canned. He just needs to grow up or go lone-wolf-coder where he can live in his own special world.

      --
      ---- Teach Peace. It's Cheaper Than War.
    2. Re:Ya to me sounds like "I'm special" syndrome by dcollins · · Score: 1

      A tantrum such as from the OP suggests to me "special" in the sense of maybe-dyslexic or something; some notable abnormality in being able to spell and format correctly.

      --
      We know where leadership by an anti-intellectual "strongman" who scapegoats minorities and likes boisterous rallies goes
    3. Re:Ya to me sounds like "I'm special" syndrome by Shinobi · · Score: 1

      That's the funny thing, any serious freelancers will follow their clients code formatting guidelines etc, specifically because it's their code we're developing, not our own.

    4. Re:Ya to me sounds like "I'm special" syndrome by postbigbang · · Score: 1

      That's if they're working on a team-based-project or doing code maintenance, or generally playingwellwithothers.

      --
      ---- Teach Peace. It's Cheaper Than War.
    5. Re:Ya to me sounds like "I'm special" syndrome by richlv · · Score: 1

      either that, or totally failing to understand that somebody else will have to work on the code at some point.

      i've seen a very strong correlation between being pedantic about coding style/formatting/standards and turning out good code (less bugs/objections during code review - and not just about formatting...).

      the ones who claim that "minor" things don't matter end up producing a massive mess. of course, it's not their fault, it's all the fault of those other pesky guys, the ones that waste hundreds of hours in code reviews and cleaning up all that mess...

      --
      Rich
    6. Re:Ya to me sounds like "I'm special" syndrome by Anonymous Coward · · Score: 0

      That's good as long as the client's code also follows their guidelines.

      How many of you have had to work on old code that seems to have had multiple contradictory formatting guidelines?

      Which do you follow? The style in the particular module, or the new style in the guidelines?

    7. Re:Ya to me sounds like "I'm special" syndrome by Anonymous Coward · · Score: 0

      In the young, it's a sign of immaturity. In the old, it may be a sign that you have learned a few things:

      1. That coding standards tend to be written by the more authoritarian members of a team, and as such typically go far beyond what is actually required. Also, they often fight their own "turf wars" through these standards (e.g. changing the company bracing style from ANSI back to K&R just because).
      2. That coding standards haven't changed much since the 80s, even though IDE features now remove the need for many of their clauses (since hovering or "find definition" tells you in a millisecond things like the type, the place of definition, if it's global, etc. etc.)
      3. That coding standards often hinder comprehension of code by forcing you to do things in an unnatural way (e.g. all classes in their own file? really?)

      Show me a set of coding standards which does all of: aims for minimalism, acknowledges the last 20 years' progress in IDE technology, and allows for exceptions with good reason, and I'll eat my hat.

    8. Re:Ya to me sounds like "I'm special" syndrome by IBitOBear · · Score: 1

      Treating all programmers as interchangable morons who cannot be trusted to write code is a sign of managerial immaturity.

      An outstanding programmer often knows when rules must be broken. Just as an outstanding jazz musician knows when to use dischord.

      Now just because the Dunning-Kruger effect causes programmatic noobs to assume they are masters deserving of liberty doesn't mean that the masters are a-priori being immature.

      Fault: there is too much baby in this bathwater. Get a seive before proceeding. Session closed... 8-)

      --
      Innocent people shouldn't be forced to pay for inferior software development.
      --"Code Complete" Microsoft Press
    9. Re:Ya to me sounds like "I'm special" syndrome by postbigbang · · Score: 1

      Your hat isn't of interest, and the world isn't perfect.

      What is of interest is code that can be maintained, often by groups/teams or QA or patch-n-fixers in a systematic approach to sanity. While IDEs both enforce style and make some of the coding standards easier to understand within the context of the IDE, plentiful organizations do hand-crafted, state of the art, stupid things and nothing saves stupid code. But that's not the question at hand.

      Minimalism isn't necessarily the right philosophy-- clarity is.

      IDEs change, too. Even IDEs have problems. See clarity.

      Exceptions, when they're necessary, have to happen, but not as often as some think (or try to get away with).

      I have sympathy for the pain that's needed to comply. That sympathy doesn't extend beyond realistic boundaries where realism is watching someone dive through a library that contained scifi function calls written to get past a deadline.

      --
      ---- Teach Peace. It's Cheaper Than War.
    10. Re:Ya to me sounds like "I'm special" syndrome by postbigbang · · Score: 1

      None of that was done; I have high respect for coders, and have managed projects. Whether outstanding or inexperienced, each can be discordant when it's proven why dischord is appropriate. Often it isn't. But code that must be maintained across teams, boundaries, revisions, and decades of use requires maintaining the disciplines needed.

      I let people do their work. There is a place where all of the people in the project, including coders, artists-formerly-known-as-whatever, QA, SAs, have to march lockstep. Stupid code is still stupid code. Unreadable code still can't be read. This isn't about the composition, this is about putting the notes on the stave and getting the orchestra to play when the damn thing boots.

      --
      ---- Teach Peace. It's Cheaper Than War.
  47. Really? by Anonymous Coward · · Score: 0

    Wow, i hadn't expected the anally retentive crowd to be so big.

    Since IDEs these days have loadable code-formatting rulesets it's as easy as having some simple rules in your project.

    A - This is the formatting ruleset, it's checked in, use it
    B - If you don't like it, make one for yourself, check it in and use it
    C - If you open someone's code and you feel your bum muscles tighten up, just pick your personal ruleset and press Shift+Ctrl+F (or whatever does it in your IDE)

    And most important, NEVER talk to the project-manager (that would be me) about coding style.
    Invest the whining time in writing your ruleset and give me a brake.

    Saves a full man-month in a big project.

    1. Re:Really? by Anonymous Coward · · Score: 0

      I usually avoid talking to the PM altogether. I find that a bigger waste of time than trying to remember what arbitrary naming convention some developer used for a function I need to call.

  48. It helps by Cro+Magnon · · Score: 5, Informative

    Once I was put on a project with rather strict standards. I didn't like their naming conventions, and the style was noticeably different from mine. But I soon found that whichever of their programs I was assigned to, it was relatively easy to follow because of the similarity with the other programs in that system. In contrast, the system I'd been on before had no standards, and everyone did things their own way (including me), and I had to study each new program before making any significant changes.

    --
    Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
  49. I'm a bit surprised by the question by _Lint_ · · Score: 1

    Most modern programming environments do enforce coding standards. We use Eclipse, and have project-wide format standards. As for it being a 'coding standard': I've always considered coding standards and formatting standards to be different things. Code reveiws are for coding standards, not for picking nits on whitespace. That said, you don't submit your code for review until you feel it's ready to submit it to the revision control system, so i don't know why you still have whitespace issues in your code.

    1. Re: I'm a bit surprised by the question by _Lint_ · · Score: 1

      Opps. when I said "Most modern programming environments do enforce coding standards" i *meant* that they enforce *formatting* standards.

  50. You should code in Google's "Go" language by Anonymous Coward · · Score: 0

    We live in the future, why don't our tools enforce these standards automagically?"

    The Go developers specify an official coding style standard, and they provide a tool to rewrite your source according to their standard. They heavily encourage everyone to automatically run all source through the tool on each checkin. Their FAQ has a kind of amusing take on the issue, which says something like: "You may not like our coding style, but no style is inherently better than any other. Consistency more important than any personal style preference. So deal with it."

  51. No studies by nicoleb_x · · Score: 1

    Of course there are no studies because everybody just KNOWS it matters.

    I switch between javascript, C#, html and sql all day long, and once in a while some php. I can even deal with minified javascript if I have to.

    1. Re:No studies by trg83 · · Score: 1

      Studies are a poor substitute for experience. Most web developers switch code all day long, but that doesn't mean each language or set of similar languages don't benefit from common formatting.

  52. I got your "reachable chunk" right here... by Impy+the+Impiuos+Imp · · Score: 1

    Coding standards are to reduce the chance of bugs. They are not bugs per se.

    Coding reviews are worthless in most situations. People look for coding standards violations more than they do for the error the standard is trying to prevent.

    Tools should be written not just to look for violations, but wherever possible, look for the bug the standard is trying to prevent.

    I also recall humerous "dualing checkins" where two guys, using different tools, kept overriding each other's coding standard fixes.

    One kept adding a default case to a switch because the standard demands it. The other kept removing it because it was flagged as unreachable because all possible cases had been handled already.

    --
    (-1: Post disagrees with my already-settled worldview) is not a valid mod option.
  53. You wasted valuable company time by Anonymous Coward · · Score: 0

    I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms

    Actually your coworkers lost hundreds of hours in code reviews because you were sloppy and did not care about your code being readable. You should fix your code before even bothering them about a review.
    Strict coding styles are good because when they are enforced you spend zero time wondering how to name variables or format code. You spend time actually writing good, readable code. This StackExchange question has a lot of insight on the topic.

  54. What IDE are you using? by wesleyjconnor · · Score: 1

    If it doesn't have an auto format you can tailor to the company standard get one.
    Alt shift f is your friend...

  55. And mod it sideways ... by Anonymous Coward · · Score: 0

    ... if you can't spot the troll.

  56. I'm Surprised It Took So Long to Front Page by ios+and+web+coder · · Score: 2

    I saw this story very early this morning.

    Regardless of the reason for it being posted, it's a good conversation to have.

    I think that consistent coding style is extremely important. There's a heck of a lot of sacred cows and third rails out there, when it comes to exactly what those coding styles should be. I'm not comfortable dictating to others what is best. I think that is likely to defeat the purpose.

    Unless you feel like nursemaiding your own code for the entirety of your career, then using a consistent style is directly to your own benefit, as that means that you can easily turn it over and move on to newer, more interesting things.

    In my own experience, developing a style (which includes commenting) is something that quickly becomes rote. You don't even think about writing good code. It just happens.

    Pascal was developed as a teaching language. It enforced a certain level of style. Python enforces it even more, by doing things like insisting that whitespace be spaces, and that indents make a big difference in terms of context and scope.

    When I became a C programmer (after using Pascal), my style quickly degenerated into Caveman Gothic. I had to re-learn a decent style.

    What helped me a lot, was using Doxygen. It's a fantastic utility that helps turn comments into documentation. I had used HeaderDoc and JavaDoc before, but they never caught on in my workflow. Nowadays, pretty much everything I write is Doxygen-commented. I actually feel physically uncomfortable when I write code without Doxygen comments (like a quick one-off test function).

    Working on a team helps. Having someone come over to you every two minutes, asking the most simplistic questions, trains you to write "leave me alone" code.

    Once you've been writing consistent code style for a while, you don't even think about it. Even my quick n' dirty routines are extremely well-structured.

    I have a certain style, which involves things like function and class names, variable and data member names, indenting, use of certain language primitives, etc. It is not ironclad, but I find it flows pretty naturally.

    --

    "For every complex problem there is an answer that is clear, simple, and wrong."

    -H. L. Mencken

  57. Yes and no by davidwr · · Score: 1

    If the stylistic issues are likely to cost significant effort down the road, they need to be brought up.

    It may be better to bring them up 1-on-1 with the developer, but they need to be brought up.

    On the other hand, if "non-standard" stylistic issues won't cost significant effort down the road, then I agree, drop it.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  58. You do have tools... by Anonymous Coward · · Score: 0

    Ever heard of indent and similar?

    Just configure them specifications of the project, write your code however the hell you want, and run indent to clean it up before submitting.

    Wont help you for naming conventions, though

  59. One day, and it won't be long by caywen · · Score: 1

    One day, if you work hard enough and get your stuff done, if you impress people with dedication and skill all the while letting the unimportant things flow as water under the bridge, you will get to make the rules. And when you do, I hope to see you asking Slashdot in a new context.

    1. Re:One day, and it won't be long by DrVxD · · Score: 1

      +1 - where are my mod points when I need 'em.

      --
      Not everything that can be measured matters; Not everything that matters can be measured.
  60. The objective... by blackcoot · · Score: 3, Informative

    Is to achieve this: http://www.joelonsoftware.com/articles/Wrong.html -- make things that are wrong be more obviously wrong. Using discipline and coding standards is just one part of the appropriately paranoid developer's defensive programming toolkit.

    1. Re:The objective... by Anonymous Coward · · Score: 0

      Yes, because if the coder can't be bothered to do the simplest and most basic things asked then every single thing they do is suspect.

  61. Yes by Ziggitz · · Score: 1

    Coding standards are important. What you're describing is much more code formatting, most decent IDE's can accept coding templates that will allow the auto format feature to conform to your company's formatting standards. When I think coding standards I think, defensively checking for null values, not chaining method calls, always using braces with if statements for java users and keeping code complexity as low as possible while meeting the requirements. The goals of coding standards are to keep code human readable and avoid common pitfalls of bad coding habits. Besides, you should take pride in your written code and make it as presentable as possible.

    --
    There is no memory shortage. yes I have heard of XFCE. Go away.
    1. Re:Yes by Anonymous Coward · · Score: 0

      ..., not chaining method calls, ...

      Please elaborate. I am not familiar with chaining method calls, but quick look-up on the web returned no warning alerts.

  62. Tools, tools, tools by Anonymous Coward · · Score: 0

    Last time I had to do this, the "Official Coding Style" started with, "Use the supplied formatting XML file and keep the files in that format." Which, solves all the issues of spacing and braces and what-not. This makes it easier to read. And it keeps the version control free of dueling developers checking in bunches of formatting changes along with the interesting code changes. Of course, they get changed back when the other guy makes changes in there. (You could fix this if the "diff" tools, whether supplied with the version control or not, were smart enough to ignore superficial formatting changes but I can't imagine how the display would effectively show real changes in the midst of the formatting changes it was ignoring. Fortunately there are people smarter than me to figure that out.)

    Added a little about questionable or confusing coding practices like using a variable for two or three things or over-factoring or doing things in a complex and possibly "faster" manner when you don't know that the simple way is too slow. You know the drill. Suggested the use of good sense.

    Then I got down to the part about naming conventions, etc. Stuff like using English verbs and nouns in the right places in the names. Avoiding abbreviations and shortened forms of words, mostly. Comment as much as necessary and as little as possible because the code explains itself. (Oh, and, you have to make the code do that, too.) Keep the blocks of code small enough to mostly see on a single screen. Trying to imagine yourself reading the code in two or three years (or heavily sedated) and being able to understand it. (There are tools that can do this for specific languages but they take time to get set up so they yield interesting reports and I haven't figured out whether its worth the time or not. Flagging something as needing a fix when it really doesn't is such a pain.)

  63. I see the problem right there by davidwr · · Score: 3, Funny

    man gofmt

    In many shops, this will generate an error:

    'man' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Users\Programmer1>

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    1. Re:I see the problem right there by trg83 · · Score: 1

      In that case, you should get a better OS before you worry about coding standards.

    2. Re:I see the problem right there by Anonymous Coward · · Score: 0

      The list of things that Windows will happily try to execute when typing in commands is downright scary.

      Also: here's a nickel, kid.

  64. Use a script or a tool to reformat the code by LordZardoz · · Score: 1

    Pretty much everyone here has already said it. Coding standards to help productivity, but its a group thing. ie: its more of a a +3% to +5% gain for everyone who has to share code and know what the hell is going on. Coding to a standard that is not a habit for yourself is going to be a bit of a hit to your own productivity.

    So if you hate dealing with the existing code standard, you could either implement a script to do the reformatting for you, or you can find an existing tool to do the same. Write however the hell feels natural, and when its working, run the conversion script and retest. If possible, convert in both directions (ie, go from official standard to your preference before you start modifying it again). It wont help structural issues (ie, if using certain design patterns is forbidden), but it will deal with the camel case vs underscore, variable name prefixes, space vs tab, and where the hell to put curly braces.

    END COMMUNICATION

  65. OT .sig by davidwr · · Score: 1

    Ezekiel 23:20

    LOL, talk about taking things out of context!!!

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  66. This should be automated. by WhitePanther5000 · · Score: 1

    As other have pointed out: Yes.

    But if you're spending time trying to remember coding style semantics, and others are spending time correcting you... then you're doing it wrong. Spend half an hour setting up your editor to automate spacing, formatting, etc. If your editor can not do this, then find a better editor.

    Additionally, require code to pass some sort of automated style check (like cstyle) before check-in. It might require a little initial setup, but it will save a ton of time in the long run.

  67. Yes. Use your tools. by Just+Some+Guy · · Score: 1

    I'm writing Python in Sublime Text 2 and use the SublimeLinter plugin. Follow basic coding standards like Python's PEP-8 or pylint is trivial as uncompliant code is highlighted as I type. When it's so easy to comply, why on earth not?

    --
    Dewey, what part of this looks like authorities should be involved?
  68. Not All Standards Are Created Equal by bossk538 · · Score: 1

    It's been a while since I read _Code Complete_, but I believe it does cite a number of studies suggesting productivity increases with certain coding conventions. But not all conventions are created equal. Having everyone use the same indentation is essential, and does hurt productivity when it isn't adhered to. Naming conventions make code tidy and more predictable, but in my experience does little or nothing for productivity. Others are just nitpicky and useless - for example in a previous job, the expression in all return statements was required to to be enclosed in parentheses - or even just plain stupid, as Hungarian notation in Java code (all objects have an "o" prefix, integers have an "i", and so on), this also in the same company.

  69. In answer to the last question by cfulton · · Score: 4, Informative

    why don't our tools enforce these standards automagically?

    They do. Almost every modern IDE will format to a standard and mark code that is not to that standard. Tools like "checkstyle" can document code that is not correct during the develop or build phase. That is why no one is wasting anyone's time here having a corporate standard. Comments about how many hours where lost "picking nits over whitespace" tell the story of developers who are too uninformed, ignorant or more likely self important to follow simple guidelines that for the most part can be automated. These are exactly the type of developer I want no where near my code base. If they won't follow the style standard they sure a f&*$ won't use the DAL as intended or follow the MVC standards. They are the developers who spend 1000 hours generating their own XML parser because they don't like they way DOM or SAX work. Having a standard does not waste time, but the kind of developer who won't follow it does.

    --
    No sigs in BETA. Beta SUCKS.
  70. Resharper by Botia · · Score: 1

    Resharper does this for you. Learn the standards. Set them. Autoformat. Done.

    1. Re:Resharper by Anonymous Coward · · Score: 0

      Agree with this - just be sure to turn off all of Visual Studio's auto-formatting options or you'll get a frustrating Battle of Wills playing out on-screen.

  71. There was a post on /. (12/19) that answered this. by gcnaddict · · Score: 4, Insightful

    "How Experienced and Novice Programmers See Code

    From one of the links:

    I’m excited to see what else Mike’s research uncovers. One aspect he’s interested in is how the approach of inexperienced programmers differs from that of experienced programmers. For example, there seems to be some evidence that following variable naming conventions helps experienced programmers understand the code much quicker, while breaking these conventions leads to a severe penalty. On the other hand, inexperienced programmers seem to take about as long regardless of how the variables are named.

    -Eric Holk

    --
    Viable Slashdot alternatives: https://pipedot.org/ and http://soylentnews.org/
  72. Corrected... by davidwr · · Score: 1

    Its like reeding slashdot. Ewe come a cross sum one who can barely spel, has trouble with homophones, puts extraneous apostrophe's in, and it makes it much harder to read four some one whois used to reed. The same goes four codine. If the reviewer C's a bracket where he accepts a curley brace, even though the too ar interchangeable, its going two slow hymn down.

    Their, fixed that four ewe.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  73. Re:There was a post on /. (12/19) that answered th by gcnaddict · · Score: 1

    I should clarify that I'm quoting Eric Holk in that comment. I'm not Eric Holk.

    --
    Viable Slashdot alternatives: https://pipedot.org/ and http://soylentnews.org/
  74. Much ado bout nothing! by Anonymous Coward · · Score: 0

    What's all the fuss about? We use astyle (Artistic Style) to deal with this issue. Does the trick for C, C++, C# and Java.

  75. hmm by buddyglass · · Score: 1

    I've always felt there should be a plugin to source-control that automatically formats source files at check-in.

    1. Re:hmm by Jherico · · Score: 1

      That's fine, but that means that you can't look at a reasonable diff prior to checkin, unless your diffing tools also do the inverse formatting on checking out the old version to diff against. This means every auto-formatting option has to be deterministic and reversible. It also means your code review tools have to support it. This quickly spirals into an every growing list of requirements that rapidly becomes much more onerous than simply following the fucking standard.

      --

      Jherico

      What can the average user can do to ensure his security? "Nothing, you're screwed"

  76. First Impressions count by cyborg_zx · · Score: 1

    Apply the rules.

    If you have better rules push for them.

    If you just don't like what was chosen tough - comprimise. It's not your own project when you're working in a team.

    I do pick these things up in code review. You know why? Because if you can't be bothered to do the small easy stuff that makes my job as a reviewer easier what kind of impression do you think I'm getting of how much effort you're putting into it? This is brown M&M territory: http://www.snopes.com/music/artists/vanhalen.asp

    "The legendary "no brown M&Ms" contract clause was indeed real, but the purported motivation for it was not. The M&Ms provision was included in Van Halen's contracts not as an act of caprice, but because it served a practical purpose: to provide an easy way of determining whether the technical specifications of the contract had been thoroughly read (and complied with)."

  77. CSS right? by Anonymous Coward · · Score: 0

    We're talking about HTML and CSS right?

  78. I don't care what you're doing by Anonymous Coward · · Score: 0

    If you're doing it with other people, there *FUCKING HAS* to be a format standard that everyone understands. It's not important, so much, that they agree with it.

    You show me more than one person working on something with no standard, and I'll show you a (in a few years probably) a codebase that's so fuct, that all troubleshooting is done by that company's hardware dept. If they have no hardware dept, they soon will. Of course I call it a hardware dept, but it'll really be an underpaid IT dept.

    To anyone that operates a business with no format, I hate you.

  79. Learn your tools. by he-sk · · Score: 1

    Do Coding Standards Make a Difference?

    Yes.

    We live in the future, why don't our tools enforce these standards automagically?

    Eclipse has had a configurable code formatter for ages. I would be surprised if other tools did not have this feature.

    --
    Free Manning, jail Obama.
    1. Re:Learn your tools. by Jherico · · Score: 1

      I imagine what the original poster was hoping for was something along the lines of tools that magically converted to and from the 'standard' convention to his local standard so that he can ignore the global standard. Unfortunately this isn't really feasible given the number of items in the typically development toolchain that would have to support this functionality.

      --

      Jherico

      What can the average user can do to ensure his security? "Nothing, you're screwed"

  80. Mao's universal dress code by epine · · Score: 1

    There have many suppositions expressed here that I don't entirely buy. However, interpersonal dynamics can quickly become so rancorous that it's simpler to comply to Mao's dress code than stand apart as an artisan.

    The most important aspect of code is the thought process involving in convincing yourself that the code is correct. It hardly matters a whit is the person reading the code reads the code but fails to read the argument embedded in the subtext within the presentation about why the code actually works.

    C++ is a multiparadigmatic language. Some people hate that. Nevertheless, it can be heavily object oriented in one place, and completely generic in another. I don't find myself that any single formatting standard best emphasizes what matters to code correctness across these styles. Scope in generic code is mainly lexical. Scope in algorithms is mainly flow control. Should one automatically format the braces in the same way? Isn't that kind of like insisting that every knife has the same grip? You know, the standard rubber handle that everyone expects to feel the same way, no matter if it's a sushi knife or a steak knife or a bowie knife?

    A more severe coding standard might go all the way to specifying that every knife is sharpened with the same bevel (either double or single sided; if single sided, either left or right handed) and to the same bevel angle. Steal is steal, ya know. German, Japanese. WTF, who cares? Ditch all the bread knives. Those are just weird.

    I'd desperately like to see a study into whether rigid consistency leads to certain classes of bugs, because all eyeballs nod in agreement over the dress code. It's certainly true that people working on the code base who get used to the style will have a nice comfortable feeling. That could have good effects on code quality. But it could certainly also have bad effects that are harder to notice. Heaven forbid anyone rains on the cozy picnic with actual data.

    Utopian for Beginners

    This article is interesting but belongs to the TL;IRRO category (too long, I'd rather remain oblivious).

    Ithkuil has two seemingly incompatible ambitions: to be maximally precise but also maximally concise, capable of capturing nearly every thought that a human being could have while doing so in as few sounds as possible.

    Why don't we regiment thought, too? The ideas expressed in code would be so much more transparent if we all though about the world in the same categories.

  81. Messy code = bondo by michaelmalak · · Score: 1

    If you have messy code, it means you're not taking pride in your work, and besides, why should the rest of us have to look at that mess? Car analogy: a '68 Mustang the color of bondo. If you can't bother to paint it, it suggests maybe you didn't bother to tune it up either.

  82. Yes. by darkwing_bmf · · Score: 1

    An especially good style guide will also include rationales for why they chose particular ways of doing things. A good example is the Ada Style Guide (it's an industry standard).

    http://www.adaic.org/resources/add_content/docs/95style/95style.pdf

  83. Don't loose hundreds of hours in code reviews by SpaghettiPattern · · Score: 1

    Don't loose hundreds of hours in code reviews. Just stick to the style guides and avoid discussions. Your code will look better and will become readable to others. You make friends. And you practice basic politeness.

    I code since late 70s and believe me, your algorithms most likely aren't really that hot. Write-only programs suck.

    --

    I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
  84. If you every worked in a shop WITHOUT standards... by billybob_jcv · · Score: 1

    ... you wouldn't be asking this question.

  85. After 20 years coding... by moderators_are_w*nke · · Score: 1

    I'd say no, coding standards are pretty pointless, unless people are being deliberately difficult or obsfuscating.

    In my experience people in large companies like to write them because it's an easy thing to stick on their PDP.

    --
    "XML is like violence. If it doesn't solve your problem, use more." - Anonymous Coward
  86. Modest proposal by Anonymous Coward · · Score: 0

    Coding standards do make big codebases more readable. The funny thing is that they're so, so different everywhere. I just finished a gig with a team that liked to put opening braces on the end of the previous line; I hadn't seen that in years, and while I don't especially like it, it didn't take long to adapt to. I worked alongside an Art & Logic contractor team once, A&L has the most detailed and unique standard I've ever seen; I was complimented for following it.

    The biggest problem is code reviews: a detailed standard makes lots of opportunities for twits who want to tie work up for days because they don't like the punctuation in the comments (yes, I've seen this.) I recall a junior guy-with-big-reputation who liked to bad mouth others to management for not meeting his standards (which were not always official, but once anyone was on a review it was blocked until they were happy.)

    My answer, which I've never quite had the horsepower to try (I don't like being a lead, let alone a dev manager), is that code reviews are purely informational: they are still required, but once they are done and feedback returned, a coder is 100% free to check in. Reviewers document their opinions and coders had better document why when they reject reviewer feedback, but the reviewer is no longer an absolute gate for work they didn't do. Coders are required to solicit feedback(s), but remain responsible for what they check in; reviewers are not responsible for problems they document.

  87. TODAY'S CHALLENGE: Malbolge Style Guide by ios+and+web+coder · · Score: 1

    Malbolge is the revolutionary new answer to the tyranny of C++!

    Sadly, a style guide has yet to be developed for this amazing engineering feat.

    The brain trust on Slashdot, however, should make short work of rectifying this appalling situation.

    --

    "For every complex problem there is an answer that is clear, simple, and wrong."

    -H. L. Mencken

  88. You're wasting everyone's time by Anonymous Coward · · Score: 0

    As a result, I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms.

    What does it say about you that after so many code reviews you still haven't figured out how to write code that will pass review? You know someone will nitpick your code and you know they'll make you conform to the coding standard in the end anyway, so just follow the standard from the beginning and save everybody the time in the code review.

  89. Yes and no. by displaced80 · · Score: 1

    See, the flip-side is:

    I don't care how good your algorithm is if it's written in an obtuse, unmaintainable manner.

    There are plenty of coders (especially those new to the profession) who don't understand the value of tidy code. The smart ones quickly understand and tend to ask for some tips. That's the first (and for me, primary) reason for having a Coding Standards document.

    The second reason is to reduce friction when viewing each others' code. Local vars should be 'someVariable'. Instance vars should be '_anotherVariable'. Methods should be 'SomeFunction'. I physically twitch when I see underscores in variable names.

    But, a Coding Standards document should be clear on 'must-do' vs recommendations. We state that you should split multiple-clause IF statements tidily to avoid excessive horizontal scrolling. But we only provide recommendations on how to do brace placement.

    Every single point in a Coding Standards document should have a defensible reason to be there.

    Our CS doc is in a Wiki which lets us have a comment section for each page (and there aren't many pages overall). If anyone wants to ask why something's in there, or suggest an alternative, they're free to. The doc's existed for 9 years and is largely unchanged other than to add explanations and extra languages. We most recently added some docs on SQL stored procedure styling, since ours were abysmal - copying and pasting SQL from Management Studio's view designer is a 'go back and do it again whilst we laugh at you' offence now :)

    --
    What's the frequency, Kenneth?
    1. Re:Yes and no. by udoschuermann · · Score: 1

      There are plenty of coders (especially those new to the profession) who don't understand the value of tidy code.

      I wish I had mod points for you, as this particular issue is one of my pet-peeves. Sloppy formatting means sloppy thinking and lack of care, both of which compete directly with my trust of the author's abilities, after which the code ceases to be worth much.

      --
      --Udo.
  90. Contextually by Etriaph · · Score: 1

    In our shop we take on a lot of code from other firms and our rule is always "write your code in the style of the author if you can". Keeping it consistent on a per-project basis is a good rule of thumb.

    For projects that we develop in house I tend to encourage the Allman style and I've setup our IDEs to perform, with a key combination, automatic formatting. That way, before you commit you hit the key combination and BAM, formatted code. I think someone playing the heavy on where you put your braces or white space should have a beer and chill out; I'd be more concerned with what the code was doing rather than it being presented on a silver platter.

    If you don't comment your code you're a savage, though. :D

    --
    "It's here, but no one wants it." - The Sugar Speaker
    1. Re:Contextually by Marxdot · · Score: 1

      Allman style and verbose comments. I am disgusted.

  91. Maybe your tools don't. by Anonymous Coward · · Score: 0

    > We live in the future, why don't our tools enforce these standards automagically?"

      Here we use a Visual Studio plugin that handles all the nitpicky coding standards for us. We're free to focus on more important issues in code review.

  92. Ensure tidy code for reviews by roskakori · · Score: 1

    As a result, I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms.

    The places where I worked used a simple guide line: the author has to clean up trivial issues before submitting an item for review. In case of code, this means ensuring style conventions.

    Which in practice is trivial for reasonably popular programming languages:

    First, you rarely have to invent your own style conventions. Instead, use existing standards. For instance, there are standard coding conventions for Java and Python.

    If some guide lines do not make sense for your shop, simply change them to fit your needs. For example, PEP8 recommends a maximum line width of 79 characters. However, all our developers work a horizontal resolution of 1920, so we allow 132 characters. We also changed naming conventions from the loud and baroque SOME_CONSTANT to the calm SomeConstant.

    Next, there are tools to check these conventions such as CheckStyle and flake8. Often you can even find tools to reformat source code consistently or automatically fix trivial issues like missing blanks, for example autopep8.

    Some shops inject these tools in the commit hook of their version management and make it reject any code that does not conform. Baring that, the review moderator is required to run the style checks on the review item. If it turns out that the author still left style issues in the code, the moderator returns the item to the author and requests to clean it up.

    That way, the reviewers always get tidy code and can focus on comprehensibility, maintainability and algorithms.

    .

  93. Every Language should have Preferred Standard Form by jhumkey · · Score: 1

    It has always been explained to me (by the zealots) that the "joy and beauty" of Java (and Python) is that . . . "You don't need to write lots. Someone has probably already done that, just reuse their code."

    Fine, so I get the, lets see . . . Windowing API from vendor_A, the DB API from author_B, and the Serial I/O API from freewareProject_C.

    Great, now all I have to do is write the core, and utilize the API's that have already been written.

    But vendor_A used WhatYouCallCamelCase, author_B usednocaseatall, freewareProject_C used_under_score_variables.

    Now your central core, must reference/utilize variables/functions/objects/etc . . . of all three types.

    It'd be nice . . . if each language (like the K&R book did for "C") at least suggested a Preferred Standard Format.

    From my own experience (or just read the preceding 800 posts) indentation can become a holy war. (Seriously, I don't see how Python survives more than one coder's reformatting . . .) Be it a good or a bad standard . . . if each language at least proposed a preferred . . . then you have a shot at all the independently developed API's . . . utilizing the same format.

    Then, your core and all its references are at least "consistent" for pure visual readability. Allowing you to focus on "what it does" not "how it looks". It also has a "shot" at depersonalizing the choice. ("I know you like it like that . . . but we try to adhere to the Preferred Standard here, so . . . though I'm very sorry it disturbs you, my hands are tied." Yes, its a cop out, but it can be utilized as an argument deflating position for the better of all.)

    --
    No, I don't remember your name. But the memory mapped screen on a TRS80 from 1977 is from 15360 to 16383 if that helps.
  94. Depends on implicit content by kschendel · · Score: 1

    Whether coding standards really matter for maintainability generally depends on how much information you expect to be carried by the formatting.

    We generally assume that indentation follows block structure, so indentation standards tend to be very important. I've wasted hours over bugs that were hidden by incorrect indentation.

    Naming conventions may matter if the coding standard dictates a different styles for different scopes (e.g. LeadingCapital for global names, etc), or if type info is embedded in the name (pszFoo, lBar, etc).

    Beyond that, coding standards help readability but that's about it. That may or may not be an issue depending on the team involved; one benefit of a uniform look is that you get less of "You're stuck fixing that code forever because I can't read it".

    Whitespace standards (outside of indentation) are generally of marginal to no use IMHO. I'd follow reasonable whitespace standards, just for that uniform look, but nobody should be spending hours on it. The fancier the coding standard, particularly as it applies to variable naming, the less useful it is in general.

    You shouldn't be losing "hundreds of hours" in code reviews, though. Either you're deliberately being obtuse about things or your coding standards are insanely complex, or uselessly ambiguous. There are a number of things I don't like about the coding standard I work in now, but I stick to it anyway because it makes the code more uniform and easier to read. Have you tried doing the same?

  95. Like Magic by Anonymous Coward · · Score: 0

    Wrote a program that formated code to a defined standard, all the whitespace, endlines, and braces.... didn't change varable names though.... only took me an hour or so. Then I wrote all my code the way I liked, ( very few spaces, less keystrokes ) and ran ./autoformat code.c
    Worked like a charm

  96. Consistency tends towards readability by udoschuermann · · Score: 1

    Over the years I've seen code that has followed one standard or another, and more than my share whose only rehabilitating feature was the fact that I could tell it was a cut-and-paste mess produced by someone who frobs rather than tunes an algorithm. Clean consistency, irrespective of the particular style, has always determined my reading comfort, and therefore understanding of the code, far more than blind and across-the-board style-naziism. That and the generous application of vertical whitespace to delineate significant blocks of logic.

    When I work on my own code, I use my own preferred style. If I work on someone else's code, I do my best to adjust to that style because I'm awesome that way ;-) or maybe just respectful of other people's preference, as I would like others to treat my style with equal respect.

    --
    --Udo.
  97. LOL by Anonymous Coward · · Score: 0

    code designated for silly humans can have any coding standard they want. TOTAL ANARCHY.

    HOWEVER

    I work in the industry where my code is used in life critical avionics software. If we do not follow our coding standards, the FAA
    gets antsi... do these people really know what they are doing? Showing a lack of discipline in design and implementation just points to
    a POSSIBLE lack of consideration of all possible software problems.

  98. Giant waste of time by Pro923 · · Score: 0

    Code that i write is generally read by me, and as such I'd like to see it in a way that is most comfortable and natural for me. In the event that someone else takes it over, they can feel free to format it in whatever way they want. I personally don't understand why anyone would prefer to use spaces over tabs and never will. Forcing people to use language constructs that are unnatural and unappealing to them are inefficiant and generally a waste of time and are generally unnecessary.

    1. Re:Giant waste of time by Anonymous Coward · · Score: 0

      "Giant waste of time" is a good description of your post... and of working with you in any sort of professional software environment.

  99. Also, coding "Standards" can be more than "Style" by aix+tom · · Score: 1

    For any project with more than one or two developers, the more important part is the general layout of the project. Which stuff should go into which packages and even into which layers.

    For example the most annoying thing I encountered was one project I inherited (and choose to ditch and re-write quite soon) was where someone had used the database layer for some calculations, the middle tier for some similar calculations, and even the client side for others that where basically duplicates of the ones already present in the database layer.

  100. Real Standards not nitpicking standards by Lorens · · Score: 1

    It's not just formatting.

    Thank you for that. Indent and bracket placing standards are good for consistency, xCase and whatever are nice so that one immediately recognizes variables and functions and whatnot, but the really useful part of a coding standard is the one that says that every function has documentation block which specifies:

    - expected behavior
    - allowable inputs (NULLs, empty strings, corner cases . . .)
    - allowable outputs

  101. design and code review by Anonymous Coward · · Score: 0

    Algorithms should be covered in the design review if not specified in the requirements and not the code review.

    It is very doubtful there is any hard evidence that code reviews are useful because they are such a waste. Lint does a better job as do compilers outputting all warnings.

  102. It should be "best practices", not "style" by Anonymous Coward · · Score: 0

    Having worked professionally in the field for 8 years or so, I can say that style standards are only as good as they are small. If you have very few rules, largely in place to prevent "style wars" (as mentioned above), it is usually easy for people to agree on it and they tend not to spend too much time thinking about it.

    I have worked in places where the interest was more on defining best practices across a team of roughly 10 people (the other 50 on the extended team could do whatever they wanted since we were rarely in each others' code). This was expected to evolve as people tried new things, brought external knowledge to the company, or learned from the causes of bugs (*shock*).

    Let me be clear: almost none of these ideas were "style"! The vast majority of them were simple code-level ideas like "always initialize variables" with a "see bug #X for a reason why" reference on it such that it was obvious why you were doing this and any disputes were considered in light of preexisting hard data. This allowed an evolution toward correctness with only a superficial nod to style.

    I have worked in other places where the style guide would actively make you write brittle code and even the reviewer would say something like "I agree with you that it is a inferior but that is how we do it here so you better change it" and it was so big and applied to such a large group that it had degraded into a religion (with its own "priesthood" to enforce the law). It became such a focus of code reviews that correctness was only accomplished by accident.

    These days, I am sure that there is some balance but I am more likely to err on the side of few style rules (or none at all), as opposed to more. After all, if your developers are thinking about what the code look likes instead of what it does or how it works, your team has failed before it started.

  103. Coding standards other than comments/formatting by Anonymous Coward · · Score: 0

    I've been through the format wars, and they're mostly (but not entirely) a waste of breath. They matter only when someone is so egocentric or incompetent that they probably shouldn't be coding anyway.

    Other kinds of coding standards do improve code safety, correctness, and maintainability. I mean things like MISRA, the "C++ Coding Standards" book (ISBN 0321113586) and their kin. Standards like those block many of the blatantly unsafe practices that lead to buffer overflows, undo the short-circuit semantics of && or ||, and cause other kinds of code chaos.

  104. modify the code review process not the criteria by Anonymous Coward · · Score: 0

    Two parts to the question and answer: 1) Development processes must be efficient, otherwise they'll end-up being ineffective. What I would do is have a criteria that must be met before entering the code review process... and things likes code-style must meet the entry criteria before the code review starts, so that the code review can be focused on higher risk type changes that have been introduced. As part of that overall process, the the "low risk" criteria will be checked by "some tools, or some person" and rejected " -- do discussion -- time if $$, the submitted has not met the minimum criteria. For the team to become efficient, these "low risk" criteria must become bread-n-butter for the team. Otherwise, trivial "low-risk", "low-impact" behaviors will dominate the teams time. Publish in a very public place statistics on the process. When executives walk by and see $$ being spent because some folks just don't want to agree to disagree and move forward -- it will be somewhat embarrassing, no? 2) Coding standards improve the overall efficiency of everyone that comes in contact with the code. It' is important for team efficiency. Inconsistent code style "may" not impact product quality, but it definitely can impact the team. If your company is a an OEM relationship or engaged with consultants that have access to code thru source license or SDK, all of the folks downstream will be impacted by the inconsistencies. Naming is huge, especially for tools that are developed to parse the code for a number of purposes.

  105. that's not why by Anonymous Coward · · Score: 0

    you lost 100s of hours cause you were too much of a prima dona to follow the guidelines

  106. Only a newbie would ask such a question. by Anonymous Coward · · Score: 0

    It's about consistency which makes interpreting the code much faster. How code is written is never the point aside from it being bad good or sufficient. The intent of the code is what matters because - bugs.

  107. There are tools to enforce standards by angel'o'sphere · · Score: 1

    In the Java world are dozens of tools to enforce coding standards or at least give visual clues if they are broken.

    Checkstyle or Findbugs etc.

    However I agree, in my last project we had far to many nonsense rules. But you are not hindered by them often.

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  108. guides are mot laws by YoungManKlaus · · Score: 1

    a style guide has its merits in that it is probably easier to pick up on what is what if you follow some conventions. However, a guide must be strictly that, and not an absolute law which has to be checked and rechecked all the time. If you find code (eg. when you have to change something there) that doesn't follow your guides, refactor it, but don't waste useless hours hunting for the obscure corner-case. Also have your IDE do the checking for you and simply mark common "errors" like wrong variable naming conventions as warnings in the code (and have your build fail if you have too many warnings).

  109. Can't follow simple instructions? by il+dus · · Score: 1

    If you can't follow a simple style guideline, what does that say about the rest of your code? When reviewing code, if I start to see a pattern of not adhering to the coding standards, I'll kick it back immediately. Why? Well, if you can't figure that out, then I don't expect you can figure out whatever algorithm you're working on either.

    Coding standards are in place to enforce consistency throughout a code base and to save developer time. When reading code, you shouldn't have to be scanning for how things are indented or whether or not a bug is caused by a dangling else, you should be able to focus on the code. Looking through inconsistently formatted code takes additional time and effort - not much, but scale to a few thousand developers over a period of years, and that's a serious amount of wasted effort.

    As others have said, if you want to write code your way, do it on your own time.

    --
    "I am Dr. Freud, but you may call me.siggy."
    1. Re:Can't follow simple instructions? by lattyware · · Score: 1

      Exactly - lost hundreds of hours to code reviews for not following the style guide? Is this guy an absolute moron? Learn to write to the style given! It's not a hard task.

      --
      -- Lattyware (www.lattyware.co.uk)
  110. Yes, but... by Kjella · · Score: 1

    ...a poor standard can drag everybody down. One of my pet issues right now is a structure that exists as code, as XML and as a database structure. Except code has namespaces, classes/objects and attributes, XML has a schema with elements and attributes with namespaces and database servers have schemas, tables and columns. So when I store an element in a table, I should now call it a class... logical? Not to me, but we're at least trying to be consistently illogical so you only need one code book to decipher it.

    --
    Live today, because you never know what tomorrow brings
  111. Static code analysis by Anonymous Coward · · Score: 0

    Ever tried it before?

    One of the few things it can do is enforce something like coding standards, so that you don't have people applying their own preferences to the "standard" when verifying your code. Instead they can focus on checking your rationale rather than the number of spaces behind line 309...

  112. Yes, there are real benefits... by seebs · · Score: 2

    It is a heck of a lot easier to read code which is consistent, and it matters much more that it's consistent than which particular standard you use.

    Badly-formatted code is much better at hiding errors. If you want a starting point for learning some of what's going on, check out Kahneman's Thinking, Fast and Slow. But long story short:

    1. If I see badly-formatted code that ignores coding specs and the like, I generally start with the assumption that whatever I'm chasing down will be in that code.
    2. This is nearly always right.

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  113. Re:There was a post on /. (12/19) that answered th by Anonymous Coward · · Score: 0

    That's what they all say

  114. Let your tools do this for you by Ferromancer · · Score: 1

    Plenty of people above have posted good justifications, but pragmatically it's also painless to implement good standards. If you use visual studio, the amazing tool known as Resharper will do the style checking and correct casing and spelling for you. Since an independent third party is taking care of this, it will reduce squabbling and "hold outs". If you're cheap, there are other free tools (including the Code Analysis which comes with visual studio). If your PHB wants a published doc, just point to a decent existing standard, like the Microsoft-generated naming guidelines and coding conventions There are similar tools and published conventions for Java and C++. This is a no-brainer folks, and plenty of talented individuals have tackled this problem. Once it becomes part of your infrastructure, you can even skip most of the code reviews for naming conventions and coding style.

    --
    "Worker bees can leave
    Even drones can fly away
    The Queen is their slave."
  115. Yes.. by Anonymous Coward · · Score: 0

    All those NASA documents with NASA - National Aeronautics and Space Administration defined in the table.. when the acronym appears only once, on the cover, with the meaning spelled out. Yep, good thing the editors caught it when we left it out.

    1. Re:Yes.. by Smallpond · · Score: 2

      I usually add a definition of "TLA" just to see who's paying attention.

  116. all over the place in the Linux kernel... by Chirs · · Score: 1

    They're useful if you have multiple error conditions...just goto an error cleanup path. Also useful for skipping to the end of a loop but where you still want to do something before the next iteration.

    See nohz_kick_needed() and distribute_cfs_runtime() in at http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=kernel/sched/fair.c for examples of each scenario.

    1. Re:all over the place in the Linux kernel... by BasilBrush · · Score: 1

      Yes, the only examples being given seem to be emulating exception handling (therefore working round a language deficiency).

  117. new code should match existing code by Chirs · · Score: 1

    If someone is writing new code in the middle of existing code, and isn't matching the style of existing code, I'm *absolutely* going to bring it up in the code review.

    Totally brand new code should follow the project guidelines.

    Otherwise you get stuff like what I've worked on where you could tell who wrote what code because everyone used a different style.

  118. Automagically with StyleCop by feddas · · Score: 1

    Microsoft Visual Studio has a fairly well agreed upon way of doing this automatically with StyleCop, http://stylecop.codeplex.com/

  119. Education by Boronx · · Score: 1

    It's good as an educational tool.

  120. That's an interesting article... by Anonymous Coward · · Score: 0

    It seems, though, that he could just use type checking instead of Hungarian notation.

    The primary problem he's trying to solve in his examples is separation of code and data. HTML is code, whereas data received via the web is, obviously, data. You never execute data, and so to output a text string as HTML is always incorrect.

    typedef char html;

    So just make your function that reads CGI data return char, and make your function that writes HTML data only accept your 'html' data type. This way you don't even have to rely on people noticing the mistake because, if someone does it wrong, the compiler will bitch and moan about it.

  121. The old M&Ms trick by CODiNE · · Score: 1

    You never know, but the code reviewer could use whitespace and other coding convention rules as an easy way to check if you're a careful programmer.

    As in the old bowl of no brown M&Ms required in the Van Halen contract. A quick and easy way to tell if the concert organizers were being careful to follow all requirements and safety conditions, the band hid a requirement for a bowl of no brown M&Ms deep in their contract.

    If the bowl wasn't there or had a single brown M&M they'd know the stage and lights setup was potentially life threatening and immediately cancel the concert.

    If you can't be bothered to follow naming conventions, brackets and whitespace requirements... how can they trust you to be a careful developer?

    --
    Cwm, fjord-bank glyphs vext quiz
  122. It's about seeing bugs. by Flammon · · Score: 1

    Coding style is about seeing and avoiding bugs.

    There are a few errors in these blocks of code. In which are they easier to find?

    var inStyle = {
              j: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
            , k: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
            , l: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
              m: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
            , n: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
            , o: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
            , p: 'taciti sociosqu ad litora torquent per conubia nostra,'
            , q: 'Aenean non purus et dolor adipiscing blandit at sed tellus.'
    }


    var soNineties = {
            j: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
            k: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
            l: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
            m: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
            n: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
            o: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
            p: 'taciti sociosqu ad litora torquent per conubia nostra'.
            q: 'Aenean non purus et dolor adipiscing blandit at sed tellus.',
    }

    The compiler/interpreter will catch them for you but that just slows you down.

    1. Re:It's about seeing bugs. by allo · · Score: 1

      even the corrected code is not doing the same. you need to be more careful with your examples ;).

    2. Re:It's about seeing bugs. by Flammon · · Score: 1

      The missing comma in soNineties.p was intentional. I'm trying to show that some errors are easier to catch by just using a different style. By putting the delimiter distinctly in front and away from the strings, you create a wider separation between code and content. It is this visual separation that helps spot errors quicker, whether it is in the code or the content.

    3. Re:It's about seeing bugs. by allo · · Score: 1

      yeah, but "nostra" vs. "nostra," was not intentional, or was it?

    4. Re:It's about seeing bugs. by Flammon · · Score: 1

      Yes, that's what I was referring to in my previous comment. The soNineties.p - "nostra" vs. "nostra," was intentional.

  123. How about... by englishknnigits · · Score: 1

    read the style guide and actually follow it? That would save you the time of being corrected and the corrector the time of having to correct you. I've never seen a style guide that was too long or complicated to easily follow. You can get used to just about any style once you've worked in it and looked at it for long enough. Consistency does actually go a long way towards readability which is a definite productivity gain. You can also glean information about code from the naming conventions without even thinking about it as long as they are consistent.

  124. Of course but automate the checks FFS! by Anonymous Coward · · Score: 0

    How can one "waste" time checking for whitespaces or tabs?

    How can one "waste" time making sure .java files do NOT contain a single non-ASCII char?

    We've got very strict guidelines but we do not waste time manually eyeball searching to see if people are breaking the rules or not. We're using scripts and commit hooks etc. that do enforce them automatically.

    One example: we force every single file committed to our projects to only contain a subset of ASCII in their filenames (no spaces, no backslash, etc.).

    We do a *lot* of stuff like this. And it's all both documented and automated. For the retards who wants to argue that tabs are better than whitespaces we point them to the specs and recommandations made by Google for the Go language. gofmt FTW! (and, no, we're no a Go shop)

    Everytime I read about build scripts or whatever scripts / tools / OS issues / encoding issues due to "creative" names for filenames I can help but think the company I work for laughs all the way to the bank ; )

  125. Fix your damn tools by Jherico · · Score: 1

    As a result, I've [wasted] hundreds of hours in code reviews because [I couldn't follow instructions]

    FTFY.

    --

    Jherico

    What can the average user can do to ensure his security? "Nothing, you're screwed"

  126. Standards reduce questions. by jklovanc · · Score: 1

    Variable naming standards reduce the guesswork when referring to variable.
    If it is all caps it is a constant and can not be changed.
    If I am in some code and I need to modify or refer to the variable that hold the "total cost" it could be total_cost, totalCost or totalcost depending on how the programmer declared it. With a coding standard there is no guess work. There would be only one choice.
    If the first letter is caps it is a class name and the method is static. I don't have to check.
    I need to access an instance variable, Is there a get and set method? What does the standard say?

    Wasting hours on code reviews is caused by people refusing to follow the standard. It is a people problem not a standard problem.

    Just because it is a standard does not mean it is a good standard. There are bad standards that do cause issue but some people love them. Coding standards are a balance between pedantic nit pickers and wild free spirits. Do I really care is there is a space after the semicolon in a for statement? No but I do care about an if-then-else statement on one line. Consistency within an organization is very important. I call it "hit by a bus" theory. Code should be written so that if you are hit by a bus someone else can read and understand it.

    The issue is that what one programmer calls common sense another will call stupid. Standards create consistent code and good standards create readable code.

  127. They're very useful as a guide. by Sarusa · · Score: 1

    We've got a simple coding standard here with things like member variable prefixing, file naming, spacing (4 spaces, no tabs), etc. When you go into existing code you know what you're looking at and when you start writing a new file you don't need to decide about this_naming vs thisNaming vs ThisNaming vs GetThisItem vs thisItem vs etc. etc. etc. And you can grab the standard file header and drop it in. All in all, it saves a lot of time.

    On the other hand, we're not pedants and don't dictate brace placement or otherwise care about whitespace like 'if( this )' vs 'if (that)' because that's not a major impact on readability or editability. If we really cared we'd just have the code automatically reformatted on check-in. You just need to work with professionals - easier said than done, I know.

  128. Coding is social - don't be selfish. by Anonymous Coward · · Score: 1

    If you've lost hundreds of hours because you didn't respect the coding style to begin with, imagine how the other guy felt reviewing your code.
    If you didn't get the message after the first few hours, it's amazing they wanted to keep you around. You're obviously not a team player.
    Doing it the first time is fine. Doing it the second time, well, it happens. After that the fact that you insisted on sending in bad commits or patches is frankly insulting to the rest of your team.
    It's funny that you call the others pedants when really, insisting on delivering non-compliant patches or code is the real pedantic action here.
    Why are you so surprised that no one looked at your amazing algorithms if you couldn't get one of the basic principles of the social aspect of coding right ?
    If you can't follow the beginner's instructions, why should anyone trust your algorithms are amazing ?
    Code isn't automatically better just because it flaunts social agreements, just as you don't become as good as Linus Torvalds by being as abrasive as he is.

  129. We just implemented uncrustify to handle this. by Anonymous Coward · · Score: 0

    It runs at the developer level on save and as part of the CI build. I'm look forward to not having to spend much time in code reviews talking about formatting

  130. Screw whitespace, it's about maintainability by MichaelJ · · Score: 1

    I'll give you a coding standard that's worth having: use a prefix to clearly identify your module statics and globals. If in an OO language, your class statics and member variables, too. If I'm looking at your code and I see an assignment to a nonlocal variable, I shouldn't have to go off analyzing the entire source tree to find out what it is.

    --

    Michael J.
    Root, God, what is difference?
  131. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  132. I HATE THE TAB CHARACTER by Anonymous Coward · · Score: 0

    Kill it with fire! The tab character sux!!!!

    And Python is super-lame for white-space being significant. FAIL!!!

    Happy Mayan Apocalypse, everyone!

  133. Code review? by mrquagmire · · Score: 1

    What is this "code review" you speak of?

    --
    giggity
  134. As a VPE for the last N years... by Anonymous Coward · · Score: 0

    ... I have 2 rules for my team:

    1) if you are modifying a file/component/module/... then you MUST follow the style of the code you are modifying
    2) If I don't understand your code, then this is YOUR problem, not mine

    Worked really well so far.

  135. Depends on how big the coding standard is by HighPerformanceCoder · · Score: 1
    Having worked for one team that had a large, detailed coding standard - 100s of items, references to books that introduced another few 100 items, plus a whole bunch of undocumented standards that get discovered in code review, I can say that even after a year in the place, my coding performance was impacted, and coding reviews spent an enormous amount of time on style things.

    In another place I worked at, there was perhaps only a dozen coding style items, every developer had their own style of working, and the crazy thing was it worked. You got used to the other coders' "accents" after a while, and the good thing was you didn't need to think too hard about the coding standard, nor waste much time in reviews.

    So yeah - it depends.

  136. Good for your eyes by Anonymous Coward · · Score: 0

    Programming involves reading a lot of code. You basically read code 8 hours a day. So your brain needs to perform a lot of pattern recogition. It helps probably most people if the code has a consistent style across a language. Because it helps recognition. (Mind the "re" syllable in the word recognition. It basically means seeing something *again*). I am one of these people that get severely distracted by code that falls out of the common formatting rules. It is simply harder to read. It's easy to misread such code (think of boolean/arithmetic expressions, control flow, block structure). There apparently are people that are less sensitive to messy coding standards. But all of them that I know are bad programmers too.

  137. Respect the file/module by LostMyBeaver · · Score: 1

    I agree that standard coding techniques are a good thing. I prefer however to focus it towards and existing file or module. If a file was written in a given style, follow that style. It makes the file readable.

    Generally I have found that working with a pile of libraries written by third parties, there's no way you can be sure that you'll have a full product with a single given coding style. So, you're already used to calling outside of your own module using alternative coding styles. But when you mix the coding styles heavily in a given file and worse, in a given function, it becomes unreadable.

    Things can easily get carried away of course. If you look at gstreamer, the variance between modules regarding coding style is a nightmare. Product is great and I always enjoyed working on it, but there's so little consistency in the system due to being overly complex that some people will do the bare minimum to get their code working with it and then just code an entirely different way after that. It would have worked better of course if people would make an attempt to move their integration code into a separate file and make the transition between files instead of strictly between modules.

    I'm hoping at some point that tools like swing will also allow making borders between like languages to have a method of enforcing coding style at the edges of modules.

  138. Non-Whitespace standards can be very harmful. by IBitOBear · · Score: 1

    True Story: Consider these two rules...

    (1) Getters and Setters must be used for all local varialbe access.

    (2) No function may be defined within the class definition body, and must instead be in the corresponding translation unit. (in C++ terms, you have to put all your member functions in the .cpp file and not the .h file etc.

    So now every get/set operation (e.g. a register load or store) is turned into a far (inter-moudlue, cross translation-unit, unoptimizable) call, with arguments, stack frame, etc., to a remote function to do the register load/store.

    Create a variable with that microsoft horror where you prefex the variable name with its type "lpszFileName" (long pointer to zero terminated string named FileName) and then change the underlying type after you have written all the code so that some long pointer to int is now a long pointer to a long but it still says int, or is now an opaque 16-bit value instead of a pointer at all but the names in countless blocks of code still lie.

    And as far as the whitespace thing, I have a unicode non-break space with your name on it, particularly if you write in Python.

    Coding standards that are _dumb_ can be _incredibly_ _dumb_ in many hidden ways.

    --
    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press
  139. (In support) by IBitOBear · · Score: 1

    Most "coding standard bugs" are hidden in a meta-level of reasoning that is harder to find than solving actual crap code.

    True Story: Working at a medical equipment manufacturer writing C++. These two atomic rules, placed far away from one aonther in the standard made a mess. See if you can spot the mess.

    (A) No member function may be defined within the class definition, and instead must be defined in the translation unit for that class. [e.g. you have to put the member definitions in the .cpp file not the .h file, so "class X { ... void foo() { /* implementation */} }; is not legal.]

    (B) Access to member data may only take place via "getter" and "setter" functions. [as opposed to putting the varialbes in the "public:" part of the class.]

    Both harmelss enough by themselves. But I opened a crap-ton of bugs on this issue because the two rules taken together turned simple register load/store operations into unoptimizeable far calls between translation units for each get/set operation. So I put my getters and setters in the class definitions like a sort of sane person (I didn't try to force sanity on them complely and just make some of the trivial values public, as I don't think they could have taken the strain) and, as required by the version control integration with the codeing standards enforcement and bug tracking tools, I filed a request for exception for every single damn such usage and let them choke on their procedure.

    But there was a reason that only _my_ code didn't run over its CPU time budget.

      A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. -- Emerson.

    --
    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press
  140. Re:Standards are (_Not_ Usually) Good (nor bad) by IBitOBear · · Score: 3, Insightful

    Standards and enforcement of same is (usually) a symptomp of the "interchangeable morons" school of management. It presumes that all problems have a (ayn rand-ish) uniform solution that all _programmers_ will process identically.

    A small number of "do not do"s with a "unless you have good cause" _guidelines_ are reasonable, but something as firm as a "standard" is a great way to make your great programmers no better than your worst over time.

    Standards often contain bugs themselves. Things that create a hidden cost on the programmer and the program that can bog both down.

    examples:

    Even Microsofte eventually abandoned their "Standard" for putting the variable type as encoded dirt on the front of their varialbe names such as "lpintThingy" having plagued their code with Thingies that are no longer long pointers to integers and that cannot be globally searched and replaced because that hazards destroying other code.

    Combined rule failure (use getters and setters + don't put member function definitions inside of class definitions => what would be a register load operation becomes an optimization resistant far call across translation units ** every dang time you set or read a scalar).

    If you cannot trust your programmers to write good code then making them format it so it _looks_ like good code is a wasted effort.

    If you cannot trust your great programmers to write great code eventually they will stop even trying to do so and you will be left with a hassle avoiding idiot or someone looking for a new job.

    If you cannot trust your new programmers to understand your previous code then your new programmers are probably inferrior to your older coders.

    If you are not winnowing out the _bad_ programmers via rational code review then your management is useless.

    All but the most rudimentary coding guidelines are productivity and creativity and performance murderers.

    Every company eventually realizes this, on and off, for a while, each time a management team ages into a job, and then forgets it again when they hire new managers.

    --
    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press
  141. And yet, you are wrong to "find it impossible..." by IBitOBear · · Score: 1

    I have worked on projects that loast hundreds of millions of CPU cycles because the coding standards encoded individual ideals into runtime performance killers. (the example I have placed elsewhere is "must use getters/setters" and "may not put function defintions inside class definitions" turns "class foo { int X; ... int getX() const {return X} };" (which can be optimized down to a register load) into a (not optimizeable at all) far call from each point of use into the foo.o (object file) after a potential PIC (position independent code) fixup for a shared library.

    And this stupidity can waste a _lot_ of man hours. In order to get my part of the medical device that _that_ coding standards bug was written under, to run in acceptable time (e.g. to not overuse my CPU time budget in a freaking real-time heart monitoring ap) I had to break the coding standard and put the getters/setter (or occasionally the plain "public" variable) into the class definition anyway, then run it into the version control system, then go through the "naughty programmer" output list and create a bug report for each such optimization and assign that bug to that "naughty naughty" message. Then the bug review team had to deal with those bugs. Then the code review team had to approve those optimizations.

    Even with this only costing me a couple of hours on the one set of modules, when you consider the ten or twelve people that the automation systme then had to nag, and the hours _they_ lost. you get into a lot of wasted time over all.

    Now add the part where once every _other_ programmer who silently followed the automatically enforced rules ran over time-budget for their code (so the system was too slow), and all _their_ code had to be fixed once everybody noticed that _mine_ was not so plagued.

    Then the cost of the project running late and eventually being determined to be "not worth the effort being expended" and getting canceled outright...

    Well, truely hundreds of man hours and _many_ thousands of dollars were wasted on a project that was largely killed because all the programmers were muzzled into paralysis by a huge steaming pile of these sorts of pointless restrictions (many of which would have been good for a _class_ in programming but most of which were _toxic_ to a real project).

    Well, you know, there are reasons that failed projects fail, and sometimes those reasons involve over-regimentation of the otherwise creative process of finding solutions and expressing those in code.

    --
    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press
  142. Being A Better Programmer by assertation · · Score: 2

    For most of my career I was one of those programmers who clinged to his own particular style of coding. I got away with it because I used an IDE that could rearrange other people's code into my style for me to work on it and then put it back in the other style when I was done.

    A few years ago I spent a lot of time studying new stuff on my platform where all the code was written in a style I didn't like and that I had always told myself made things harder to read.

    I got over myself as a result.

    I think I became a better programmer by reading code written in different styles.

    I now think it is the mark of a provincial thinking to cling to your own style at the expense of good relations at your job.

  143. been there, answered that by Tom · · Score: 1

    If you write code strictly on your own, you probably don't need a document, because - if you are a good programmer - you already have a style.

    But as soon as you work with a team, you need a document. Reading code written by others, understanding what it does, spotting bugs and a dozen other things are just so much easier if everyone uses the same style and that style makes sense and was written to support good code, not just some arbitrary orderliness desire.

    For my main project, our Style Manual is about 3 pages, including examples. Also, we don't fuss over minor details, many guidelines are that exactly - guidelines. Many are "should" rules, because we realize that there are some cases where an exception makes sense.

    But yes, it was worth it and it helps. When you have a team, a style guide is very helpful. But like all things, it can be overdone, and if someone whines about whitespaces, for me personally that's the point where it becomes crazy. Heck, your editor probably has a "reindent everything" command. Use that, done.

    --
    Assorted stuff I do sometimes: Lemuria.org
  144. You forgot $omething in your variables... by Tenebrousedge · · Score: 0

    PHP's original problem was that generating HTML is actually not all that hard. You didn't need all of those fancy real-language features; that would just create a barrier to entry!

    "Well, apparently it's a little harder than we thought, so we'll add some things to the language and then it will be okay!"

    The recent phenomenon of using Javascript on the server is the exact same pattern.

    --
    Those who advocate genocide deserve every protection afforded by law, and none afforded by common human decency.
    1. Re:You forgot $omething in your variables... by Anonymous Coward · · Score: 0

      puss tools for wannabes.

  145. Haircuts by LQ · · Score: 1

    Why do all soldiers have to have the same haircut? It's about reducing individuality and being assimilated into the squad.

    Sticking to coding standards reduces the sin of code ownership.

  146. In a word yes. by ebvwfbw · · Score: 1

    Whitespace used to be a big deal. Certainly with RG8, Fortran, lesser extent Cobol. Real languages it isn't so important. Standardizing how things is done is. So when I call something that was written by another group, I expect it to return something like our group has. Same type structures and so on. They should make sense. Otherwise it will introduce errors. Errors that can be exploited or errors that cause unpredictable things to happen.

    Today I write my stuff such that any idiot could look at it and use it. That's because in 10-15 years I might be that idiot who needs to fix something. What was I thinking? Oh yea - here it is. Over the years I've been complimented for how clear my stuff is.

    Whitespace can be fixed quickly by the way. Just use an editor like Emacs that supports ws macros. Set it up, tab and it's where it's supposed to be. Just set up a macro and Whoosh! It's right. I'm sure you could also use perl or C with the right program.

    (Macro in emacs - control-x left paren. This example - escape (top of file), control-x leftparen (define macro), control-n (next line), tab, control-x rightparen (end macro). Control-u 5000 control-x e (execute macro 5000 times). Macros can be very powerful.

  147. Re:Every Language should have Preferred Standard F by lattyware · · Score: 1

    Python has PEP-8, which is followed pretty well by most projects.

    --
    -- Lattyware (www.lattyware.co.uk)
  148. Hundreds of hours? by flacco · · Score: 1

    "As a result, I've lost hundreds of hours in code reviews because some pedant was more interested in picking nits over whitespace than actually reviewing my algorithms"

    Stop coding like shit, then. Adopt your organization's coding standards, or lobby to have them changed if they're dumb.

    --
    pr0n - keeping monitor glass spotless since 1981.
  149. Everybody gets what they want. by Anonymous Coward · · Score: 0

    I worked at one place where the coding standard was a pre-comit hook on our version control. Before you checked in, it got formatted to match the standard, so diffs were at a minimum. Don't like that standard? Use a hook on checkout to format it the way you want.

    It was great, because it killed holy wars. You like spaces? Use spaces. You like your braces like this {
    }, fine.

    It doesn't handle everything, but it got some of the benefits, without the arguments about what the one, true standard was.

  150. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  151. They will until... by xkpe · · Score: 1

    They will until we all use editors that understand canonical representation of the source code and restyle it according to a personal preference.

    As a software developer for more than 15 years I'm amazed why we still used this archaic system of writing text for developing software.

  152. This is the right way to do it by davidwr · · Score: 1

    In any large project or any highly-regulated project like medical equipment, this is exactly the right way to do things.

    The only change I would've made would be to start the bureaucratic process of changing the coding standard itself to explicitly allow or even recommend that "simple" getter and setter functions go in the .h file, for the very reason you were doing it.

    Because this is a medical equipment setup where people can die if things go wrong, I would err on the side of caution when defining "simple": Basically, if it's a simple copy operation of a simple data value that is obviously bug-free by inspection (well, as obvious as anything can be "by inspection" - which is to say 99.9+%), it goes in .h, no questions asked. Otherwise, either put it in .cpp or request an exception. The idea is that by requesting an exception, more eyeballs will look at the code.

    If this wasn't a "people can get killed" scenario, I'd be a lot looser with standards-enforcement.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  153. Duh, our tools DO do it automagically by Anonymous Coward · · Score: 0

    We live in the future, why don't our tools enforce these standards automagically?

    If your tools don't do this, they suck. Get better tools.

    For instance in Vim you can set the indentation and tab options for C and make the editor indent everything automagically. Likewise in Emacs.

    Of course in some shitty IDE it's impossible to do this, and thus people spend countless hours moving whitespace around in a tool which is supposed to increase productivity.

    And we have the rules for readability. So that there's one less burden for understanding. Code is complex as is, without having to understand Harry the Wonder Hacker's peculiar whitespace and indentation excercises.

  154. Coding standards are the LAST thing to worry about by prof_braino · · Score: 1

    ... testable requirements, and executing those tests, are much more important and come first. This is the big secret that separates the engineers from the hackers If requirements and tests are in place, then standards are useful, otherwise they are a distraction.

  155. You can't fix stupid by Anonymous Coward · · Score: 0

    I work in a place where coding standards are rigidly enforced. And we work with a large data warehouse, where they have managed to name any given data element differently in pretty much every single table in which it appears. Do we really need to name the column which contains the zip code zip_cd, to save two characters, not when storing it (as in the reason for the y2k crisis), but when typing it in; sometimes, that is, when we're not naming that column zp_cd or just zip, or sometimes even zip_code? But damn it all, we're going to make up for that by naming the datasets in our programs uniformly: data1, data2, data3, etc; or merge1, merge2, merge3, etc. Because that is certainly better than naming them something terribly confusing, like "members_with_no_dependents" or "purchases_by_members_with_no_dependents".

  156. You don't want to _know_ about the broken stuff by IBitOBear · · Score: 1

    I did try to get the coding standard fixed.

    Meanwhile, elsewhere in the code, in full compliance with the coding standards I found:

    (1) unconditional static down-casts from base types to derived classes despite the possibility of error event classes being the return value. (e.g. class A, A_failed, and B, where B and A_failed were derived from A, and then a key static cast from A* to B* without any check for A_failed at all.)

    (2) shaving down (bit shifting and masking) pointers through a void* arg and then into four bytes (char) that were then pushed into a byte queue, where they were later popped off as four bytes and shifted back into a pointer some type. (The "real time programmer" who came from a VX works background didn't believe in just making an array of void* and moving all the bytes at once for whatever retarded reason.) [also broken because the A* to void* to B* three-way conversion isn't necessarily safe since it should be cast to A*, reinterpret_cast to void*, then reinterpret_cast to A* then dynamic_cast to B* to be safe and symmetric.]

    (3) so many unsafe operations at in the module call prototypes that I eventually just made my code "correct" (e.g. call-safe) then put a conversion layer that used the unsafe API in both directions and called that translation unit "unsafe.cc" and had lots of forwarding functions spelled out why the calling convention was flirting with disaster so that all the unsafe calls and unsafe casts were all in one pile and in one place.

    Item 3 was somewhat insurrectionalist because I wasn't allowed to get any of my criticisms to be acknowledged by, or then past my boss who's "it worked when we tested the prototype code that one time" attitude kept things tightly broken.

    So we had nicely regimented coding standards but I always look at the brand name of any medical equipment I see sitting next to a bed now because I know what the code base for one particular brand really looks like and how much they didn't give a rats ass about doing things right (as opposed to doing things they way someone decided they should be done based on single test runs).

    That guy who noticed that if we build buildings the way we built software, the first woodpecker to come along would destroy civilization? Yeah, he wasn't exactly wrong.

    --
    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press
  157. re: .sig by davidwr · · Score: 1

    Quoting from your signature:

    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press

    Oh, the irony.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  158. Re: .sig by IBitOBear · · Score: 1

    The irony is completely the point of the signature and it's attribution.

    --
    Innocent people shouldn't be forced to pay for inferior software development.
    --"Code Complete" Microsoft Press
  159. You will understand by cwsumner · · Score: 1

    You will understand when you have to work on other people's code. With no time to re-format everything and six other programmers that like his way better.

    If you can not do more than one format (or more than one language for that matter), then you are still new. 8-)
    But more than one format in a project, is a pain, even if the one they specify is not yours.