NASA’s Rules For Writing Mission Critical Code

NASA’s Rules For Writing Mission Critical Code

When you’re NASA, developing critical applications that lives literally depend on (code that controls aeroplanes and spacecraft, for example), code quality and safety are paramount. That’s why they have been looking into coding standards or rules to ensure the reliability of critical software.

Photo by Traveller-Reini.

The guidelines were developed by the Jet Propulsion Laboratory (JPL) at the California Institute of Technology, under a contract with NASA, and are currently being used experimentally, with encouraging results, at JPL. While it focuses on code written in C because of the language’s long history and extensive tools support, the guidelines could be adapted for other programming languages and used even if your software programs won’t be used to launch aircraft.

There are 10 rules, to make the set small and clear enough to remember. Some of them are broadly accepted standards for good coding style and practices, such as declaring data objects at the smallest level of scope (rule number 6) and checking code daily with at least one source code analyser (rule 10).

Some might appear strict or confining, such as rule number four:

No function should be longer than what can be printed on a single sheet of paper in a standard reference format with one line per statement and one line per declaration. Typically, this means no more than about 60 lines of code per function.
 
Rationale: Each function should be a logical unit in the code that is understandable and verifiable as a unit. It is much harder to understand a logical unit that spans multiple screens on a computer display or multiple pages when printed. Excessively long functions are often a sign of poorly structured code.

As the guidelines paper notes, however, these rules are meant to make it possible to make mission critical code clearer, easier to analyse, and ultimately safer.

Check out the PDF below for the ten rules and their rationales.

The Power of Ten – Rules for Developing Safety Critical Code (PDF) [Pixels Commander via JAXenter]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


One response to “NASA’s Rules For Writing Mission Critical Code”