Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming

Ask Slashdot: Do Coding Standards Make a Difference? 430

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?"
This discussion has been archived. No new comments can be posted.

Ask Slashdot: Do Coding Standards Make a Difference?

Comments Filter:
  • by rs79 ( 71822 ) <hostmaster@open-rsc.org> on Friday December 21, 2012 @03:28PM (#42362725) Homepage

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

    • by man_of_mr_e ( 217855 ) on Friday December 21, 2012 @03:48PM (#42363027)

      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.

      • Re: (Score:2, Informative)

        by casings ( 257363 )

        Most diffs can ignore whitespace...

        I don't understand your second point.

        • by Decameron81 ( 628548 ) on Friday December 21, 2012 @03:56PM (#42363115)

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

          • by casings ( 257363 )

            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

            • by Decameron81 ( 628548 ) on Friday December 21, 2012 @04:18PM (#42363405)

              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.

              • by UnknownSoldier ( 67820 ) on Friday December 21, 2012 @04:27PM (#42363517)

                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 [wikipedia.org] ) , just as long as EVERYONE follows them.

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

                  5

              • by casings ( 257363 ) on Friday December 21, 2012 @04:54PM (#42363815)

                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.

                • by luis_a_espinal ( 1810296 ) on Friday December 21, 2012 @05:12PM (#42364021)

                  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.

                • by lgw ( 121541 ) on Friday December 21, 2012 @06:08PM (#42364625) Journal

                  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.

            • Re: (Score:3, Interesting)

              by Anonymous Coward

              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 stan

          • Re: (Score:3, Funny)

            by Anonymous Coward
            You're probably the finicky person who keeps complaining about my rot13 variable names. To each their own, buddy.
          • by mk1004 ( 2488060 )

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

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

          • by DrVxD ( 184537 ) on Saturday December 22, 2012 @11:52AM (#42369333) Homepage Journal

            CodingStandardsThatMandateCamelCaseDecreaseReadability.

            coding_standards_that_mandate_underscores_increase_readability.

        • Most diffs can ignore whitespace...

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

        • by BasilBrush ( 643681 ) on Friday December 21, 2012 @04:00PM (#42363169)

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

          You didn't understand his first point.

    • by gantzm ( 212617 ) on Friday December 21, 2012 @03:53PM (#42363091)

      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.

    • 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.
  • by who_stole_my_kidneys ( 1956012 ) on Friday December 21, 2012 @03:29PM (#42362733)
    because when you leave\get fired\DIE, everyone can read your code and not have to interpret it, thus productivity gained.
    • by Anonymous Coward on Friday December 21, 2012 @03:47PM (#42363009)

      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

    • by s.petry ( 762400 )

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

  • by account_deleted ( 4530225 ) on Friday December 21, 2012 @03:29PM (#42362737)
    Comment removed based on user account deletion
    • by Shimbo ( 100005 )

      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.

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

    • by IBitOBear ( 410965 ) on Saturday December 22, 2012 @07:22AM (#42368195) Homepage Journal

      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.

  • Yes, they do (Score:5, Insightful)

    by Anonymous Coward on Friday December 21, 2012 @03:30PM (#42362749)

    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.

    • by Sycraft-fu ( 314770 ) on Friday December 21, 2012 @03:48PM (#42363023)

      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.

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

    • Re:Yes, they do (Score:5, Insightful)

      by WaffleMonster ( 969671 ) on Friday December 21, 2012 @04:18PM (#42363399)

      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.

  • by Smallpond ( 221300 ) on Friday December 21, 2012 @03:30PM (#42362755) Homepage Journal

    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.

  • by beelsebob ( 529313 ) on Friday December 21, 2012 @03:30PM (#42362759)

    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.

    • by caywen ( 942955 )

      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.

    • by mwvdlee ( 775178 ) on Friday December 21, 2012 @04:06PM (#42363237) Homepage

      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.

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

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

  • by pclminion ( 145572 ) on Friday December 21, 2012 @03:32PM (#42362781)

    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.

  • by AuMatar ( 183847 ) on Friday December 21, 2012 @03:32PM (#42362791)

    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.

  • Tools support (Score:4, Informative)

    by K. S. Kyosuke ( 729550 ) on Friday December 21, 2012 @03:32PM (#42362795)

    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.

  • by TheNinjaroach ( 878876 ) on Friday December 21, 2012 @03:32PM (#42362799)
    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.
    • Re: (Score:2, Insightful)

      by Anonymous Coward

      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.

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

  • by decipher_saint ( 72686 ) on Friday December 21, 2012 @03:32PM (#42362805)

    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.

  • 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?
  • It's a test on following orders and attention to detail. We don't need any of you rogue coders 'round here, see?

  • by jackb_guppy ( 204733 ) on Friday December 21, 2012 @03:35PM (#42362849)

    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!

  • 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 famili
  • by TheGratefulNet ( 143330 ) on Friday December 21, 2012 @03:37PM (#42362887)

    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.

  • by neiras ( 723124 ) on Friday December 21, 2012 @03:38PM (#42362907)

    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.

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

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

  • It helps (Score:5, Informative)

    by Cro Magnon ( 467622 ) on Friday December 21, 2012 @03:49PM (#42363035) Homepage Journal

    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.

  • 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 [doxygen.nl]. 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.

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

  • The objective... (Score:4, Informative)

    by blackcoot ( 124938 ) on Friday December 21, 2012 @03:59PM (#42363155)

    Is to achieve this: http://www.joelonsoftware.com/articles/Wrong.html [joelonsoftware.com] -- 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.

  • 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 hum
  • 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 how

  • I'm writing Python in Sublime Text 2 and use the SublimeLinter [github.com] 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?

  • by cfulton ( 543949 ) on Friday December 21, 2012 @04:05PM (#42363229)

    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.

  • by gcnaddict ( 841664 ) on Friday December 21, 2012 @04:07PM (#42363249)

    "How Experienced and Novice Programmers See Code [slashdot.org]

    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

  • I've always felt there should be a plugin to source-control that automatically formats source files at check-in.
  • 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 [snopes.com]

    "The legendary

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

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

  • by seebs ( 15766 ) on Friday December 21, 2012 @06:26PM (#42364869) Homepage

    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.

  • by assertation ( 1255714 ) on Saturday December 22, 2012 @08:51AM (#42368429)

    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.

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...