Ten rules when writing life-related code



When writing a serious code that involves one mistake involving life or a few years of effort, what kind of point should I be aware of? Nasa's computer engineer Gerard J. Holzmann Thinks "The Power of 10"It is summarized as.

The Power of 10: Rules for Developing Safety-Critical Code - Wikipedia
https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code

1. Avoid complicated flows such as Goto and recursion

Byatsunori kohsaki

2. Set an upper limit on the number of loops to prevent runaway

ByWoplu

3.Heap areaDo not allocate memory of


This is because the used memory may not be released successfully and cause a memory leak.

4. Summarize functions as small as they can be displayed on one page


5. At least 2 per functionAssertionTo attach


You can lower the possibility of causing an error by rejecting unexpected input.

6. Summarize scopes as small as possible


7. Check if the return value is not void and return void if the return value is meaningless


8. Use preprocessor sparingly


The use of the preprocessor is something like twice translating which requires only one time. There is a danger of causing unintended bugs if you do not understand the detailed behavior of the preprocessor.

9. The use of pointers is a singleDereferenceUntil then,Function pointerDo not use


10. Compile is done with setting to warn as much as possible, and fix it by the time of release


Overall, "readability" seems to be very important.

in Note,   Software, Posted by log1d_ts