There are many ways to write a program that meets the design specifications. A program may be shorter or run more quickly than other and in that sense, be the better program. However, program maintenance is fast becoming as important as performance.

Structured programming is a method designed to make programs easier to maintain. Structured programs are easy to read, debug, and maintain because they follow a set of rules. A COBOL structured program is designed and written in a logical hierarchy containing:

  • Three control logic structures—sequence, selection, and iteration
  • One entry and one exit
  • Modularity (programs, subprograms, sections, or paragraphs)
  • Consistent indentation that shows control flow and nesting
  • Data-names and paragraph-names that accurately describe their functions
  • Comments that describe function, not implementation
  • Blank lines to separate logical constructions

A well-structured program clearly illustrates the relationship between the program listing and program execution. A structured program can be read in sequence from top to bottom. A structured program does not contain GO TO, ALTER, or ENTRY statements. A structured program is built from logically related parts. The parts of a structured program, that is, control logic structures, combine the following:

  • Sequence (simple sequence of functions)
  • Selection (selection of functions, for example IF... THEN, CASE, EVALUATE, etc.)
  • Iteration (loop control, for example DO WHILE, PERFORM UNTIL, etc.)

Statements controlled by the selection and iteration structures are indented to make the scope of the structure visually obvious in the listing. These structures are combined into the functional segments of a structured program. The segments may be as short as a few statements, and should be no longer than one page of code (about 50 lines). Each segment has just one entry and one exit.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

IBM Mainframe Topics