rc3.org

Strong opinions, weakly held

The argument for strict coding standards

cbloom rants on the value of strict coding standards:

Strict coding standards are actually an intellectual relief because they remove all those decisions and give you a specific way to do the syntax. (The same of course goes for reading other people’s code – your eyes can immediately start looking at the functionality, not try to figure out the current syntax)

Don’t forget that adherence to coding standards also produces higher quality diffs.

7 Comments

  1. Agreed 100%. Unfortunately, in some projects I’ve been part of over the past few years, any attempt to clean up existing code to meet a standard meets with such strenuous howls from the folks who prioritize retaining the revision history of each line of code (via svn/git blame) over consistently readable easy-to-edit code that the code remains a mess forever.

  2. One easy solution I’ve found to deal with this is have a commit trigger that formats the code to the standard (and general housekeeping like changing tabs to spaces (or vice versa), stripping trailing spaces, etc.

    Then it doesn’t matter what dogma people cling to. Checking in ends the argument. For those (like me) who like extra spaces around parenthesis, curly brackets on the same line, etc., my IDE does it automatically. When I check in, all my formatting mutations are erased, but I don’t care because it didn’t cost me any time to make them.

  3. I agree with this point. It also takes distracting “religious debates” over preferred naming conventions, spacing, etc. off the table.

    I prefer to use static analysis tools and gated checkins (e.g., allow 0 warnings from the tools) to enforce coding standards, so that code reviews can focus on design.

    @daveadams – That’s unfortunate. When doing a mass cleanup, I typically note “cleanup only” in the checkin comments. That way, the reader can re-run blame on the prior revision. Yes, it’s an extra step and you have to correlate the code you’re looking at to the pre-cleanup revision, but blame should be relatively rare. Is that such a burden for those protestors?

  4. The biggest coding standards burden I’ve seen is when you have developers on multiple platforms and you see “converting characters to proper newlines” commit messages from Windows/Unix developers. 🙂

  5. bryan: commit trigger sounds interesting for code formatting, any pointers to tools and/or documents on that?

  6. @bryan, do you find that when you re-visit that bit of code, your brain would have to readjust to the new formatting? I know I would.

  7. In my experience those who oppose the most against code cleanup are the same people who still don’t see a reason to switch from SVN to Git (or any DVCS). But Subversion users hardly use blame/praise at all, since it’s just so damn slow.

Leave a Reply

Your email address will not be published.

*

© 2016 rc3.org

Theme by Anders NorenUp ↑