--- On Wed, 31/8/11, Blue Swirl <blauwir...@gmail.com> wrote: > I agree about importance of consistency, though I'd even go > further and reformat globally. New code gets introduced > based on copying old code so the pain goes on.
I think this is the most important point. I've worked on many projects where coding standards were applied, generally the order is: 1) Someone comes up with some new standards 2) They want to dictate the standards but are not prepared to invest any effort in making the existing code base conform to those standards 3) They decide it's too high risk to modify existing code 4) In conclusion they apply the coding standards to new code only 5) Some... time... passes 6) Evangelist(s) responsible for coding standards leave the team *or* Are convinced by other developers that coding standards suck 7) Repeat from 1), or drop coding standards I've seen this pattern pretty much without fail, over the last 20 years of commercial software development. You never reach the standards utopia unless you retrospectively change all existing code. The only way you ever want to do that is if you have either a) Extensive unit tests or b) Balls Preferably both! So what generally happens in experienced teams, is that you either re-work (only) the modules you touch, or you identify the coding standard of the module you're working on or the ones nearby and follow them. Alternatively some developers write coding standards in a rather vague way such that there are no hard and fast rules. They categorise types of problem and their severity rather than using all rules as rejection criteria. Couple of examples come to mind: When developing either driver or device emulation software it's nice to use the same identifiers as the data sheet. By forcing everything to lower case it makes it harder to cross-reference things, and God forbid if the data sheet actually used case to distinguish registers you'd then have to invent identifiers to deal with it. I looked around to see which license I could use, cribbed one from another Qemu file, and then promptly had to reformat it because it broke the line length rule, so I've reformated what was previously a standard license and crafted my own for no other reason that conforming with checkpatch.pl. cheers, Biff.