Ada 95 Quality and Style Guide Chapter 2

Chapter 2: Source Code Presentation - TOC - 2.1 CODE FORMATTING

2.1.6 Blank Lines

guideline

  • Use blank lines to group logically related lines of text (NASA 1987).

    example

        if ... then
           for ... loop
           end loop;
        end if;
    

    This example separates different kinds of declarations with blank lines:

        type Employee_Record is
           record
              Legal_Name    : Name;
              Date_Of_Birth : Date;
              Date_Of_Hire  : Date;
              Salary        : Money;
           end record;
        type Day is
              (Monday,    Tuesday,   Wednesday, Thursday,  Friday,
               Saturday,  Sunday);
        subtype Weekday is Day range Monday   .. Friday;
        subtype Weekend is Day range Saturday .. Sunday;
    

    rationale

    When blank lines are used in a thoughtful and consistent manner, sections of related code are more visible to readers.

    automation notes

    Automatic formatters do not enforce this guideline well because the decision on where to insert blank lines is a semantic one. However, many formatters have the ability to leave existing blank lines intact. Thus, you can manually insert the lines and not lose the effect when you run such a formatter.


  • < Previous Page Search Contents Index Next Page >
    1 2 3 4 5 6 7 8 9 10 11
    TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC
    Appendix References Bibliography