Serial THRU Clauses

A serial THRU clause is one by which the PERFORM statement invokes two or more paragraphs in succession, of which none contains a GO TO.

For example:

     PERFORM 2200-VALIDATE-SSN 
      THRU 2400-VALIDATE-DATE-OF-BIRTH.
     ...
 2200-VALIDATE-SSN.
* some code here -- but no GO TO

 2300-VALIDATE-NAME.
* some code here -- but no GO TO

 2400-VALIDATE-DATE-OF-BIRTH.
* some code here -- but no GO TO
Replace the original PERFORM statement with:
     PERFORM 2200-VALIDATE-SSN.
     PERFORM 2300-VALIDATE-NAME.
     PERFORM 2400-VALIDATE-DATE-OF-BIRTH.
This transformation is useful because it eliminates some fall-through logic, and safe because it cannot disrupt any remaining fall-through logic.

Sometimes the object of the THRU clause is a trivial EXIT paragraph. If there is no other reference to the EXIT paragraph, eliminate it.

If the original PERFORM THRU turns into a long series of simple PERFORMs, you may be tempted to collect them into a separate paragraph, such as 2100-VALIDATE-RECORD. Resist this temptation for now -- unless you can find a safe place to put the new paragraph, where control will not fall into it by accident. For example, perhaps the preceding paragraph always exits by a GO TO.


[style forum]COBOL Style Forum [spaghetti]Spaghetti code [stage]Next stage
[home]COBOL Home