Reason: Excessively long functions are often a sign of poor structure. This means a function shouldn’t have more than 60 lines of code. No function should be longer than what could be printed on a single sheet of paper in a standard reference format with one line per declaration and one line per statement. One way to dynamically claim memory in the absence of memory allocation from the heap is to use stack memory. Overstepping boundaries on allocated memoryįorcing all modules to live within a fixed, pre-allocated storage area can eliminate these problems and make it easier to verify memory use.Continuing to use memory after it was freed.Attempting to allocate more memory than physically available.Moreover, memory errors can also occur because of a programmer’s mistake, which includes Reason: Memory allocators like malloc, and garbage collectors often have unpredictable behavior that can exceptionally impact performance. 3 – No Dynamic Memory Allocationĭo not use dynamic memory allocation after initialization. In such cases, the reverse rule is applied – It must be statically provable that iteration cannot terminate. However, the rule doesn’t apply to iterations that are meant to be non-terminating (for example, process scheduler). Reason: The presence of loop bounds and the absence of recursion prevent runaway code. The rule is considered violated if the loop-bound can’t be proven statically. It should be possible for a verification tool to prove statically that a preset upper-bound on the number of iteration of a loop can’t be exceeded. 2 – Fixed Upper Bound for LoopsĪll loops must have a fixed upper-bound. Thus, all executions that are supposed to be bounded remains actually bounded. Without recursion, there will be no cyclic function call graph. Reason: Simple control flow results in improved code clarity and stronger capabilities for verification. Write programs with very simple control flow constructs – Do not use setjmp or longjmp constructs, goto statements, and direct or indirect recursion. They all primarily focus on security parameters, and you could apply them to other programming languages as well. For instance, software programs used to control airplanes, spacecraft, or nuclear power plants.īut do you know what standards space agencies use to operate their machines? Below, we have listed NASA’s 10 coding rules laid by JPL lead scientist Gerard J. In critical cases, it becomes necessary to apply these rules, especially where human life may depend on its correctness and efficiency. This is because there is extensive tool support for this language, such as logic model extractors, debuggers, stable compiler, strong source code analyzers, and metrics tools. In fact, many agencies, including NASA’s Jet Propulsion Laboratory (JPL), focus on code written in C programming language. The world’s top programmers working at NASA follow a set of guidelines for developing safety-critical code. In order to be effective, the set of rules has to be small and must be specific enough that it can be easily understood and remembered. Usually, they determine:ī) Which language feature should or should not be used? These guidelines establish the ground rules that must be followed while writing software. Large and complex software projects use various coding standards and guidelines.
0 Comments
Leave a Reply. |