Home > Articles > Programming > .NET and Windows Programming

Coding Guidelines: Fact and Fiction

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Close Window

Derek M. Jones

Learn more…

Sorry, this author hasn't posted any blogs.

Derek M. Jones looks at low-level coding errors and the use of coding guidelines as a cost-effective means of avoiding some of the more common instances of such errors.

Introduction

Faults in software can have very expensive consequences. For some applications, often known as high-integrity applications, there is a significant probability that software faults can result in death or serious injury to people. There are many ways in which faults can be created; for instance, they can be high-level design mistakes or low-level coding errors. This article looks at low-level coding errors and the use of coding guidelines as a method of avoiding some of the more common instances of this kind of error.

While coding guidelines are generally perceived by management to be a good thing, companies are rarely willing to make the necessary investment in either the production or enforcement of such guidelines. Consequently, most of the recommendations contained in many of these documents have no proven causal connection to faults in software. The net result is that many experienced developers don’t consider the recommendations contained in coding guideline documents to have a positive value.

The current renewed interest in coding guidelines is being driven by external factors. Customers have noticed that faults in software regularly cost them lots of money, and they’re starting to demand some level of software quality assurance from their suppliers. Requiring that software suppliers adhere to an appropriate set of coding guidelines provides confidence that at least some of the commonly known faults have been avoided.

This customer-driven focus has resulted in coding guideline documents being produced by industry groups; for instance, the Motor Industry Software Reliability Association (MISRA) has produced the MISRA-C guidelines, targeted at the automobile industry. This industry-wide approach spreads the development costs and creates an attractive market into which independent tool vendors can sell. In September 2005, interest in this area became "official" with the formation of the first international standards group. The purpose of this group is to produce a standard aimed at reducing software faults in high-integrity applications through the use of various kinds of coding guidelines.

In many ways, the concern about faults in software causing death and serious injury has been proactive. Very few deaths have been directly attributed to faults in software. One of the few cases of death by software fault, and the most widely quoted, is the masses overdoses of radiation caused by the Therac-25. Here, the deaths of six people were directly attributed to faulty software. The fact that this case occurred more than 20 years ago shows how rare such events have been to date (or perhaps how difficult it is to prove that faulty software was the root cause).

To ensure that guidelines are followed, the code must be checked. Performing the checks before a program starts to execute is the ideal; having to handle the error conditions generated by checks that failed during program execution introduces a great deal of complexity. Checks performed before a program executes are known as static analysis, and tools that automatically perform such checks are known as static analysis tools. (Dynamic analysis refers to guideline checks performed during program execution.) Static analysis that is performed by people often goes by the name of code review.

  • Share ThisShare This
  • Your Account

Discussions

Make a New Comment

You must log in in order to post a comment.

Related Resources

Danny KalevMinutes from the October 2009 Meeting
By Danny Kalev on Yesterday No Comments

The minutes from the Santa Cruz (October 2009) meeting are available here. Even if you're not a language layer at heart, I encourage you to read them.

Danny KalevA Reader's Opinion on Attributes
By Danny Kalev on October 20, 2009 No Comments

In August I dedicated a series to the debate about C++0x attributes. I believe that it covered the subject in a balanced and detailed way, but I keep getting complaints from C++ users who don't like attributes for various reasons. Here's a recent email I received from a Polish C++ programmer. While it  doesn't represent my opinion about attributes -- I'm rather neutral about this feature and consider it a "solution waiting for a problem" -- but it suggests that attributes are still a highly controversial issue that will haunt C++ for a long time. The email is quoted here with minor edits that and as usual, with all private details removed.

Danny KalevFollowup: The Web 2.0 Guy I Ain't
By Danny Kalev on October 16, 2009 1 Comment

Almost a year ago, I posted here The Web 2.0 Guy I Ain't. People wonder whether I still resist all those Web 2.0 features and technologies at the end of 2009.

See All Related Blogs

There are currently no related titles. Please check back later.

Informit Network