Fall-Through Logic

In COBOL, the term "fall-through logic" refers to the following situation:

How Fall-Through Logic Occurs

Fall-through logic can occur in three ways:
  1. The program invokes a paragraph with a GO TO;
  2. The program invokes a paragraph with PERFORM THRU;
  3. The code at the beginning of the PROCEDURE DIVISION (or immediately following an ENTRY statement) does not STOP RUN or GOBACK, directly or indirectly, before the next paragraph.

Why It's Bad

In each case, the code specifying the fall-through is remote from the code where the fall-through occurs.

To understand such a paragraph, you can't just look at the paragraph itself; you have to look at the code which invokes it. As a result, the flow of control is difficult to discern. A program may even invoke a paragraph in two or three different ways, sometimes falling through and sometimes not.

Fall-through logic is also a standing invitation to maintenance problems. If someone rearranges the paragraphs, or inserts a new paragraph in the wrong place, the change disrupts the intended path of execution.

One common practice is to PERFORM THRU, letting control fall into a trivial paragraph that does nothing but EXIT. This form of fall-through logic may appear benign. Nevertheless it invites all the same problems, and offers no benefit.


[home]COBOL Home [style forum]COBOL Style Forum