Updtaed
2009.02.22
The purpose of a program
standard is to make it easier to understand programs, to develop coding
techniques that reduce the complexity of programs, and to control the entire
software development effort. The following guidelines are adapted from the book
COBOL With Style
by Henry Ledgard.
FILES
·
With our compiler, Cobol files always have the
extension “.cbl”.
·
In this class, data files will always have the extension “.txt”.
·
In this class, “printer” files will always have the extension “.prn”.
·
In this class, error files will always have the extension “.err”.
·
Always turn in hard copies of your "cbl", "prn",
and "err" files.
·
Always print your full name as the first line of all output files (both
prn and err).
GENERAL
RULES
- Between
each division, section, or paragraph, there must be a page eject or a
sequence of blank lines that is longer than the maximum sequence of blank
lines within the previous division, section, or paragraph. (e.g. use 3
blank lines between divisions, 2 blank lines between sections, and 1 blank
line between paragraphs)
- Place
division headers, section headers, and paragraph names on lines by
themselves.
- Do
not break words or numeric constants across lines.
- Begin
every comment line with "***".
- Continuation
lines must be indented at least two spaces from the starting
position of the previous line.
IDENTIFICATION DIVISION.
- Always
include the following paragraphs:
Author.
Program-ID.
- Always
include comments that give a brief description of the program's purpose,
the required inputs, and the expected outputs.
DATA DIVISION.
- All
data items that remain constant throughout a program must be initialized
in a VALUE clause. Use the traditional convention of using all caps for
names of constants.
- Start
level indicators (FD, SD, CD, RD) and 01 level
numbers at column 10.
- The
level numbers of immediately subordinate items of a group item must be
indented at least two spaces (four would be better) from the
starting position of the level number of the group item.
- In
an FD, SD, CD, or RD entry with multiple clauses, place each clause on a
separate line, indenting each clause at least two spaces from the
starting position of the entry name.
PROCEDURE DIVISION.
- The
maximum length of a paragraph is one page.
- GO
TO statements are not allowed.
- Use
the COMPUTE verb for arithmetic computations.
- Begin
each statement on a new line.
- Align
the starting positions of the statements making up a sentence and the
sentences making up a paragraph. The general rule is to align logically
parallel constructs.
- The
word ELSE should be aligned with the corresponding word IF. The statements
in the IF part and the ELSE part must be indented at least two spaces.
- Place
phrases such as AT END, WHEN, INVALID KEY, GIVING, USING, TALLYING,
VARYING, UNTIL, and AFTER on separate lines, indenting the start of each
phrase at least two spaces to the right.