Coding conventions gone haywire

I generally have coding standards that I follow for every language I write in. For the most part, they make my code more readable and make spotting errors easier. Sometimes a business has standards that don't make sense. And sometimes, they are flat out horrible. StackOverflow has a thread all about the worst coding conventions seen in the workplace.

All C/C++ arrays shall start at index 1, instead of 0. Indeed, the use of 0 as first index of an array is obsolete, and has been superseded by Visual Basic 6's insightful array index management.

... and:

a friend of mine - we'll call him CodeMonkey - got his first job out of college [many years ago] doing in-house development in COBOL. His first program was rejected as 'not complying with our standards' because it used... [shudder!] nested IF statements

the coding standards banned the use of nested IF statements

now, CodeMonkey was not shy and was certain of his abilities, so he persisted in asking everyone up the chain and down the aisle why this rule existed. Most claimed they did not know, some made up stuff about 'readability', and finally one person remembered the original reason: the first version of the COBOL compiler they used had a bug and didn't handle nested IF statements correctly.

This compiler bug, of course, had been fixed for at least a decade, but no one had challenged the standards. [baaa!]

CodeMonkey was successful in getting the standards changed - eventually!

Coding conventions are good practice, but the best advice I can give in general is to use the conventions everyone else uses for the language you are using unless you have a damn good reason not to.


Add new comment