Coding standards are always a hot topic in development teams, with people arguing for and against them as a whole, and then disagreeing over the actual detail. I don’t think I’ve seen two companies with the same coding standards.
We can agree there isn’t a recognised standard for coding. Microsoft have produced standards over the years, sometimes based on Hungarian notation, but there isn’t a widely accepted standard.
The task of a software developer is to produce the most efficient code he or she can to a given specification. Efficient is the key word in that statement. We tend to think of efficiency in terms of run time resources, memory, cpu cycles, etc, but we need to look a bit further. As we found out leading up to the year 2000, computer programmes are often used far longer than they were intended. I’m not sure why this is a surprise, although programming languages improve over the years, code doesn’t wear out like hardware can. Anyway, there’s a very high chance that any piece of code written will require modifying in the future and possibly by someone else. In this case the way the original code was structured has a direct impact on how quickly easily it can be understood and amended. In the late 1980’s I was working for a software house producing PC systems written in COBOL. We had a very clever programmer there who had written a complex program with just one full stop, meaning there were plenty of nested IF statements. Printed out the code was beautiful, but almost impossible to modify, a bit like putting a Paddy Hopkirk roof rack on a Ferrari, not that’s there’s anything wrong with a Paddy Hopkirk roof rack, it just wouldn’t look right on a supercar. The simple change took several hours to make and test, clearly not efficient.
My take on coding standards is that they help produce efficient code, by allowing programmers that have knowledge of the standards to understand existing code quickly and easily. In my opinion they should be rigorously applied and checked as part of the code review. Creating coding standards is a challenging task and one that will be covered in my next posting.