DEV Community

Reginald Ojunga
Reginald Ojunga

Posted on

NASA Power of 10 rules

So if you have been in the programming space long enough, you have
probably heard of Nasa's Power of 10 rules.
And these are basically a set of rules that lower chances of software
failure in mission critical software.

The first is simplify control flow. This isn't particularly an issue especially for those using current high level languages. I frankly do not know what the fuss is all about on gotos.

Provide an explicit iteration upper bound. Prevent the software from entering into an endless loop.

No dynamic memory allocation after initialization. I am uncertain how programs that perform strict static allocation handle inputs at runtime. On the upside it obviously makes sense a dynamic allocation translates to a syscall. You want to avoid those if you are trying to be fast.

Use short functions. This i believe is to help in developer experience by reducing complexity.

Use assertions. Assertions come in a set that involve either checking the value, property of the value or the value's location in memory. These are some of the ways of checking for equivalence.
And basically the purpose of assertions is to act as in-flight checks. They add a layer of redundancy.

Declare all data at the smallest scale possible. I believe this speaks to the need for performance. Smaller data structures are almost equivalent to what may be deemed as cache-conscious data structures.
They are good for both spatial and temporal locality and as a consequence they prevent cache thrashing.

Check the return value of all non-void functions. I think this can be done using assertions.

Limit pointer use. No more than one dereference. I think extensive use of pointers in any given program
is equivalent to playing russian roulette.

Finally always compile with all warnings enabled.

Most of these rules have been adopted and used to build different development cultures like Tiger Style.
Things like static allocation have been used to explain tigerbeetle's high performance.

There's a full length video on this by Gerald Holzman.

Top comments (0)