Sections, Paragraphs, and related topics

From: William M. Klein (wmklein_at_nospam.netcom.com)
Date: 12/06/04


Date: Mon, 06 Dec 2004 22:48:46 GMT

Just as a new thread, I wanted to post my observations and thoughts on this
(most previously posted).

1) It is my impression that the use of (all) SECTIONS is more common in Europe
and the use of (all) PARAGRAPHS is more common in the US. (I don't know about
Asia or Pacific or India or Canada, etc). This observation comes from my time
working at Micro Focus (and dealing with customers in both regions.)

2) It is my perception that having ALL "Sections" (possibly with a single
paragraph and/or exit paragraph) *OR* having all PARAGRAPHS is each an "equally
maintainable" style (and not error prone). While having a MIXTURE of the two is
not a "good idea" (IMHO).

3) Having numbers as the prefix of EITHER paragraphs or sections is ENTIRELY a
"style" issue and never (or rarely?) causes any maintainability or enhancement
problems. It is USEFUL with some editors (e.g. ISPF) and not useful with
others. (I have yet to see any cases where numbered procedures are "bad" - but
I can see why - in some environments - they would be useless.). I do know that
in "large IBM mainframe shops" where I have seen it used consistently (with
"normal" ranges for various functions) it can make "picking up" someone else's
code easier to understand or fix quickly. However, this is probably true for
ANY "structure" technique that is used consistently within a large shop.

4) Having a SECTION with multiple (other than just an -EXIT) paragraph within
     OR
    Having multiple PARAGRAPHS (other than an -EXIT) in a PERFORM range
is equally error-prone.

5) Some (possibly many) sites that "traditionally" have PERFORM xxxx THRU
xxxx-EXIT standards *also* have software (or at least procedures) to insure that
NO paragraph header appears between "xxxx" and "xxxx-EXIT".

6) Using the PERFORM xxxx THRU xxxx-EXIT technique (or using the SECTION with
an -EXIT procedure) provides the functionality that is provided as an extension
to the '85 Standard or in the '02 Standard of doing an "immediate exit" from
within a procedure (i.e EXIT PARAGRAPH/SECTION). Although it is POSSIBLE to
avoid this technique with switches and/or deeply nested conditionals, I think
that the ability to "exit immediately under some logic situations" is a useful
tool in COBOL. Furthermore, (IMHO) this ability outweighs any potential problems
of PERFORM ... THRU - when sufficient safeguards are in effect to avoid other
types of GO TO and/or middle-of-the range paragraph names. (I personally prefer
EXIT PARAGRAPH - as it avoids "potentially error-prone" labels - but accept
that it is not generally available.)

7) Just as a "side-note" I usually PERFORM rather than GO TO a "kill/stop the
application" procedure (such as an ABEND or EXEC CICS RETURN paragraph). I know
this isn't ever going to come back, but it is easier to insure that my
applications do NOT include any "bad" GO TO's.

8) Just as there is debate about how to "modify" OO properties (see separate
thread), there is also "debate" as to whether doing a "downward" GO TO within a
single procedure is or is not "structured" code. It *does* maintain the "single
entry / single exit" rule - but also DOES a "go to label" statement. If your
view of structured coding does NOT allow this structure *and* you feel that
following "strict structured coding" philosophy is important, then don't use it.

-- 
Bill Klein
 wmklein <at> ix.netcom.com 


Relevant Pages

  • Re: change variables
    ... Yes, but that is _your_ switch, not mine. ... put those 20 lines yet another paragraph and have Block-A perform it. ... I'm not frightened of indenting code. ... But I'm still not convinced that EXIT PARAGRAPH ...
    (comp.lang.cobol)
  • Re: Infinite Loops and Explicit Exits
    ... > coding changes are needed for a maintenance programmer to add a GO TO ... I think the addition of inline PERFORM in '85 COBOL, ... EXIT PARAGRAPH and EXIT SECTION are expressly ...
    (comp.lang.cobol)
  • Re: Avoiding Logic Error?
    ... Plinston, and what you are welcome to do. ... When a paragraph is controlled via a PERFORM, Mr Plinston - as it might ... When an EXIT PARAGRAPH is executed control is passed back to the invoking ...
    (comp.lang.cobol)
  • Re: Is it possible to use the value of the PROGRAM ID within the source code?
    ... Robert Wagner wrote in message ... >>defined as allowing for a GO TO which directed execution to the top of ... > If we had EXIT PARAGRAPH, there would be no excuse to perform THRU an exit ... Both EXIT PARAGRAPH and EXIT SECTION were added to ...
    (comp.lang.cobol)
  • Re: No paragraphs in "standard" COBOL (was: EXIT SECTION/PARAGRAPH
    ... an extension before the '02 Standard was passed. ... to exist before/without a paragraph header. ... See substantive change 90 on page 828 of the '02 Standard. ... EXIT PARAGRAPH is an extension prior to '02. ...
    (comp.lang.cobol)