Interesting items from the Joint Strike Fighter C++ coding standards.

Here are some interesting things from the JSF C++ coding standards document. They bring across some of the basic ideas commonly used in programming, or things that may seem sort-of left-of-centre.

  • Any one function (or method) will contain no more than 200 logical source lines of code.
  • There shall not be any self-modifying code.


  • Tabs should be avoided.
  • All indentations will be at least two spaces and be consistent within the same source file.
  • All words in an identifier will be separated by the ‘_’ character.
  • All acronyms in an identifier will be composed of uppercase letters.
  • The statements forming the body of an if, else if, else, while, do…while or for statement shall
    always be enclosed in braces, even if the braces form an empty block.
  • Braces (“{}”) which enclose a block will be placed in the same column, on separate lines
    directly before and after the block.


  • Functions with variable numbers of arguments shall not be used.
  • Functions with more than 7 arguments will not be used.
  • Functions will have a single exit point.
  • Functions shall not call themselves, either directly or indirectly (i.e. recursion shall not be
    allowed).  Since stack space is not unlimited, stack overflows are possible.


  • Code that is not used (commented out) shall be deleted. No dead code is allowed.
  • The purpose of every line of executable code should be explained by a comment, although
    one comment may describe more than one line of code.
  • One should avoid stating in comments what is better stated in code (i.e. do not simply repeat
    what is in the code).
  • Multiple variable declarations shall not be allowed on the same line.
  • Unencapsulated global data will be avoided.


  • Multiple variable declarations shall not be allowed on the same line.
  • An assignment expression shall be used only as the expression in an expression statement.
  • Unsigned arithmetic shall not be used.


  • Pointers to pointers should be avoided when possible.
  • The null pointer shall not be de-referenced.


  • There shall be no unreachable code.
  • Labels will not be used, except in switch statements.
  • The goto statement shall not be used. Frequent use of the goto statement tends to lead to code that is both difficult to read and maintain.
  • The continue statement shall not be used.
  • The break statement shall not be used (except to terminate the cases of a switch statement).
  • All if, else if constructs will contain either a final else clause or a comment indicating why a
    final else clause is not necessary.
  • Every non-empty case clause in a switch statement shall be terminated with a break
  • All switch statements that do not intend to test for every enumeration value shall contain a
    final default clause.
  • A switch expression will not represent a Boolean value.
  • Every switch statement will have at least two cases and a potential default.
  • Floating point variables shall not be used as loop counters.
  • Numeric variables being used within a for loop for iteration counting shall not be modified
    in the body of the loop.


  • Programmers should not attempt to prematurely optimize code.
  • Compile-time and link-time errors should be preferred over run-time errors.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s