Barr Group TwitterBarr Group Vimeo


6.2.a. All reasonable effort shall be taken to keep the length of each function limited to one printed page, or a maximum of 100 lines.

6.2.b. Whenever possible, all functions shall be made to start at the top of a printed page, except when several small functions can fit onto a single page.9

6.2.c. It is a preferred practice that all functions shall have just one exit point and it shall be via a return at the bottom of the function.

6.2.d. A prototype shall be declared for each public function in the module header file.

6.2.e. All private functions shall be declared static.    

6.2.f. Each parameter shall be explicitly declared and meaningfully named.


state_change (int event)
    int result = ERROR;

    if (EVENT_A == event)
        result = STATE_A;
        result = STATE_B;
    return (result);

Reasoning: Code reviews take place at the function level and often on paper. Each function should thus ideally be visible on a single printed page, so that flipping papers back and forth does not distract the reviewers.

Multiple return statements should be used only when it improves the readability of the code.

Enforcement: Compliance with these rules shall be checked during code reviews.


[9] One way this can be accomplished is to insert a form feed character ‘FF’ (ASCII 0x0C) at the beginning of the first line on the comment block that precedes the function definition.

What’s happening and how it’s done. Get in the know.

Sign Up for Our Newsletter

Receive free how-to articles, industry news, and the latest info on Barr Group webinars and training courses via email. 

To prevent automated spam submissions leave this field empty.