Sections Vs. Paragraphs 
Author Message
 Sections Vs. Paragraphs

Several recent posters have talked about this subject, including Richard
Plinston.  I believe that one of the scary aspects of programming is "unintended
logic flow", to coin a term for what Mr. Plinston was talking about.

Where I program, we have developed standards for COBOL programming, and finally,
after many years of trying, the proponents of disallowing the "GO" verb have
gotten their way.  "GO" and "ALTER" are just not allowed in new programs.

This made it possible for us to stop arguing about whether to use Sections or
Paragraphs - the standard requires that you use one or the other exclusively.  A
given program must be entirely constructed of paragraphs or of sections.

By the way, we have also written programs to enforce most of the standards we
expect programmers to follow.  Using the available compiler exits, we capture
the code and issue diagnostics when prohibited verbs are used, when the
paragraph vs. section rules are violated, when bad packed-decimal PIC's are
found, etc.  (Since we buy source code sometimes and own products which
generate COBOL, we don't remove verbs from the Reserved Word table, and we have
a mechanism for not checking some programs.)

If you want excellent, maintainable code, look for simple but effective
standards and follow them.
Colin Campbell



Tue, 09 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Well, just to add my $.02 worth to this conversation.......

I'm a firm believer in not using sections in my programs, unless I'm
forced into using an internal sort.  I am also a firm believer in doing a
PERFORM THRU to an exit for each paragraph in the program.  However, I not
so rigid that I never use a well-placed GO TO.   When I find a condition
that precludes any further processing in a paragraph, I will certainly use
a GO TO to send the logic of the program to the exit of that paragraph,
instead of having to repeat the same conditional test multiple times until
the exit is executed.  I think you run into trouble whenever you try to
apply absolutes to anything as fluid as a programming language like COBOL.

IMHO

Dave Bretz



Wed, 10 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Quote:

>This made it possible for us to stop arguing about whether to use Sections or
>Paragraphs - the standard requires that you use one or the other exclusively.  A
>given program must be entirely constructed of paragraphs or of sections.

How do you handle use of the SORT verb in your shop?  Watching this
and keeping in mind all of my references on COBOL, which state that
it's required to use sections for input and output procedures, what is
done?  If there's a way to do it with all paragraphs, please tell me.

Quote:
>If you want excellent, maintainable code, look for simple but effective
>standards and follow them.

here here!


Wed, 10 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Reposting article removed by rogue canceller.

Quote:

>This made it possible for us to stop arguing about whether to use Sections or
>Paragraphs - the standard requires that you use one or the other exclusively.  A
>given program must be entirely constructed of paragraphs or of sections.

How do you handle use of the SORT verb in your shop?  Watching this
and keeping in mind all of my references on COBOL, which state that
it's required to use sections for input and output procedures, what is
done?  If there's a way to do it with all paragraphs, please tell me.

Quote:
>If you want excellent, maintainable code, look for simple but effective
>standards and follow them.

here here!


Wed, 10 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Reposting article removed by rogue canceller.

Well, just to add my $.02 worth to this conversation.......

I'm a firm believer in not using sections in my programs, unless I'm
forced into using an internal sort.  I am also a firm believer in doing a
PERFORM THRU to an exit for each paragraph in the program.  However, I not
so rigid that I never use a well-placed GO TO.   When I find a condition
that precludes any further processing in a paragraph, I will certainly use
a GO TO to send the logic of the program to the exit of that paragraph,
instead of having to repeat the same conditional test multiple times until
the exit is executed.  I think you run into trouble whenever you try to
apply absolutes to anything as fluid as a programming language like COBOL.

IMHO

Dave Bretz



Wed, 10 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Quote:

> Well, just to add my $.02 worth to this conversation.......

> I'm a firm believer in not using sections in my programs, unless I'm
> forced into using an internal sort.  I am also a firm believer in doing a
> PERFORM THRU to an exit for each paragraph in the program.  However, I not
> so rigid that I never use a well-placed GO TO.   When I find a condition
> that precludes any further processing in a paragraph, I will certainly use
> a GO TO to send the logic of the program to the exit of that paragraph,
> instead of having to repeat the same conditional test multiple times until
> the exit is executed.  I think you run into trouble whenever you try to
> apply absolutes to anything as fluid as a programming language like COBOL.

> IMHO

> Dave Bretz

IMHO...
I have yet to encounter the situation in COBOL, C, C++,... in fact
just about any language other than assembly where a GO TO is needed.
I have also had to untangle many bowls of spagetti... NOT fun!
I also find that the organization forced on a program where GOTOs
are not allowed makes for a "better" more maintainable (and that
is big bucks in the real world!) code.

- Steve



Thu, 11 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Boy, there are sure a lot of humble opinions out there!<g>

Dave Bretz' comments make it sound as if he uses a 1974 ANSI COBOL compiler.
SORT verbs no longer require that the INPUT and/or OUTPUT PROCEDURE be
SECTION's. The THRU construct allows for the destruction of a program's logic by
activities as innocuous as moving blocks of code; if THRU is not used, it
can still be done, but takes a little more effort.

As Steve Townsend said, there is no such thing as a well-placed GO (TO is an
optional word).  To me, it's just a way of bailing out of poorly written logic.
I'm not sure why, twenty-plus years after the structured programming theories
were proven, people still hang onto the idea that there are situations when a GO
is useful, needed, or even required.  Maybe it is so that the ALTER verb can be
used!

Finally, proper structuring also means that tests need not be repeated.  Look at
the in-line PERFORM as one way to isolate lower-level logic while keeping it in
the same area.  The CONTINUE verb, NOT (AT) END, NOT (ON) SIZE ERROR, and scope
terminators of 1985 ANSI COBOL, especially END-IF, are also helpful in writing
clear, clean code.  EVALUATE, as a true case structure, is also very worthwhile.

COBOL has improved in many ways over the years, to the point that programs which
read COBOL can be written in COBOL, for example.  In order to use the
improvements, though, programmers have to keep learning.  The fact that the 1974
ANSI COBOL language will compile with few changes in a 1985 ANSI COBOL compiler
does not mean that one is writing modern, top-notch COBOL anymore.
Colin Campbell


Quote:

> Well, just to add my $.02 worth to this conversation.......
> I'm a firm believer in not using sections in my programs, unless I'm
> forced into using an internal sort.  I am also a firm believer in doing a
> PERFORM THRU to an exit for each paragraph in the program.  However, I not
> so rigid that I never use a well-placed GO TO.   When I find a condition
> that precludes any further processing in a paragraph, I will certainly use
> a GO TO to send the logic of the program to the exit of that paragraph,
> instead of having to repeat the same conditional test multiple times until
> the exit is executed.  I think you run into trouble whenever you try to
> apply absolutes to anything as fluid as a programming language like COBOL.

> IMHO
> Dave Bretz

>IMHO...
>I have yet to encounter the situation in COBOL, C, C++,... in fact
>just about any language other than assembly where a GO TO is needed.
>I have also had to untangle many bowls of spagetti... NOT fun!
>I also find that the organization forced on a program where GOTOs
>are not allowed makes for a "better" more maintainable (and that
>is big bucks in the real world!) code.

>- Steve



Fri, 12 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

There is one case where a GO TO is clearer and that is a GO TO to an abend
paragraph.  There may be other non-return conditions that would clarified by
using GO TO rather than PERFORM.  

Quote:
>Boy, there are sure a lot of humble opinions out there!<g>

>Dave Bretz' comments make it sound as if he uses a 1974 ANSI COBOL compiler.
>SORT verbs no longer require that the INPUT and/or OUTPUT PROCEDURE be
>SECTION's. The THRU construct allows for the destruction of a program's logic by
>activities as innocuous as moving blocks of code; if THRU is not used, it
>can still be done, but takes a little more effort.

>As Steve Townsend said, there is no such thing as a well-placed GO (TO is an
>optional word).  To me, it's just a way of bailing out of poorly written logic.
>I'm not sure why, twenty-plus years after the structured programming theories
>were proven, people still hang onto the idea that there are situations when a GO
>is useful, needed, or even required.  Maybe it is so that the ALTER verb can be
>used!

>Finally, proper structuring also means that tests need not be repeated.  Look at
>the in-line PERFORM as one way to isolate lower-level logic while keeping it in
>the same area.  The CONTINUE verb, NOT (AT) END, NOT (ON) SIZE ERROR, and scope
>terminators of 1985 ANSI COBOL, especially END-IF, are also helpful in writing
>clear, clean code.  EVALUATE, as a true case structure, is also very worthwhile.

>COBOL has improved in many ways over the years, to the point that programs which
>read COBOL can be written in COBOL, for example.  In order to use the
>improvements, though, programmers have to keep learning.  The fact that the 1974
>ANSI COBOL language will compile with few changes in a 1985 ANSI COBOL compiler
>does not mean that one is writing modern, top-notch COBOL anymore.
>Colin Campbell



>> Well, just to add my $.02 worth to this conversation.......
>> I'm a firm believer in not using sections in my programs, unless I'm
>> forced into using an internal sort.  I am also a firm believer in doing a
>> PERFORM THRU to an exit for each paragraph in the program.  However, I not
>> so rigid that I never use a well-placed GO TO.   When I find a condition
>> that precludes any further processing in a paragraph, I will certainly use
>> a GO TO to send the logic of the program to the exit of that paragraph,
>> instead of having to repeat the same conditional test multiple times until
>> the exit is executed.  I think you run into trouble whenever you try to
>> apply absolutes to anything as fluid as a programming language like COBOL.

>> IMHO
>> Dave Bretz

>>IMHO...
>>I have yet to encounter the situation in COBOL, C, C++,... in fact
>>just about any language other than assembly where a GO TO is needed.
>>I have also had to untangle many bowls of spagetti... NOT fun!
>>I also find that the organization forced on a program where GOTOs
>>are not allowed makes for a "better" more maintainable (and that
>>is big bucks in the real world!) code.

>>- Steve

Clark F. Morris, Jr.

                                                          506-657-9331

                                                           902-665-4006


Sat, 13 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Quote:

> Reposting article removed by rogue canceller.


> How do you handle use of the SORT verb in your shop?  Watching this
> and keeping in mind all of my references on COBOL, which state that
> it's required to use sections for input and output procedures, what is
> done?  If there's a way to do it with all paragraphs, please tell me.

Actually, the COBOL 85 standard allows the input and output procedure clauses to
reference a section or a paragraph name. My MVS COBOL II programmers reference vouches
that this is true for VS COBOL II as well. I agree with you entirely on the standards
issue.

:^)=

--
***********************************************************************
is it any wonder things seem so awry?
we swim in a sea of confusion and
we don't have to think to survive so nobody listens.....  


url  :   http://www.epix.net
***********************************************************************



Sat, 13 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Quote:

>I'm not sure why, twenty-plus years after the structured programming theories
>were proven, people still hang onto the idea that there are situations when

a GO
   Exactly when, how, and by whom was this "proof" published?  As I was
around twenty-plus years ago, I can state with perfect confidence that
Djikstra & Co. ASSERTED that GOTO-less code was "the way", and then a lot
of people jumped on the bandwagon and repeated the assertion, and then
another generation of programmers came along and were taught the same
thing, and, being human, believed what they were told and so propagated
the myth.  Why was there a bandwagon?  Somebody else published a study at
about the same time that "established" that comments improved code quality
and maintainability as much as did GOTO-less programming, but it got
little attention because comments were less exciting academically.  And
there, essentially, the matter remains.  It's noticeable that people who
disparage GOTO's have not, as a general rule, tried them systematically.
(Note also that "structured" does NOT equal "GOTO-less", but that's a
different matter).  If anyone wishes to challenge me I will send them a
real-world, quite simple problem which they can take the GOTO's out of,
and, if they're right, they'll be able to convince me that by MY
standards, the result is better.

Quote:
>clear, clean code.  EVALUATE, as a true case structure, is also very

 worthwhile.
  perhaps you can help me here: in what way is EVALUATE superior to a
properly-planned string of IF's?  (No contentiousness here: I really would
like to know).


Tue, 16 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs



Quote:
>> EVALUATE, as a true case structure, is also very worthwhile.
> in what way is EVALUATE superior to a properly-planned string
> of IF's?  (No contentiousness here: I really would like to know)

Sounds like a troll, but:
(a) indentation: IF ELSE IF ELSE IF can fall off the page;
(b) one END-xxx: END-EVALUATE instead of END-IF END-IF ...

--

Mine of Information Ltd,  PO BOX 1000,  St Albans AL3 5NY,  GB
=== Independent Computer Consultancy * Established in 1977 ===



Tue, 16 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Quote:


>>I'm not sure why, twenty-plus years after the structured programming theories
>>were proven, people still hang onto the idea that there are situations when
>a GO
>   Exactly when, how, and by whom was this "proof" published?  As I was
>around twenty-plus years ago, I can state with perfect confidence that
>Djikstra & Co. ASSERTED that GOTO-less code was "the way",

What Dijkstra published was an assertion that GOTOs are a bad idea, and a
rigorous mathematical proof that they are never necessary.

Dijksta, E. W. "Go To Statement Considered Harmful," Communications of the
ACM (March 1968).

and then a lot

Quote:
>of people jumped on the bandwagon and repeated the assertion, and then
>another generation of programmers came along and were taught the same
>thing, and, being human, believed what they were told and so propagated
>the myth.  Why was there a bandwagon?

Because experience showed that structured programs are superior to
spaghetti code.

Somebody else published a study at

Quote:
>about the same time that "established" that comments improved code quality
>and maintainability as much as did GOTO-less programming, but it got
>little attention because comments were less exciting academically.  And
>there, essentially, the matter remains.  It's noticeable that people who
>disparage GOTO's have not, as a general rule, tried them systematically.

Just what does it mean, to apply GOTOs "systematically" ?

Quote:
>(Note also that "structured" does NOT equal "GOTO-less", but that's a
>different matter).  If anyone wishes to challenge me I will send them a
>real-world, quite simple problem which they can take the GOTO's out of,
>and, if they're right, they'll be able to convince me that by MY
>standards, the result is better.

Doubtful, since you appear to have your mind already made up.

Doug Miller

views expressed are mine and not those of
Hospital Health Plan Corp.  "all health care is local"



Tue, 16 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

Quote:
Glenn Grotzinger writes:
> How do you handle use of the SORT verb in your shop?  Watching this
> and keeping in mind all of my references on COBOL, which state that
> it's required to use sections for input and output procedures, what is
> done?  If there's a way to do it with all paragraphs, please tell me.

My understanding was that the IBM mainframe COBOL compilers, at least,
allowed the use of paragraphs instead of requiring sections. Other areas
where the standard dictated sections: report writer and declaratives.

Regards,

Steve Comstock
Denver, Colorado
USA

telephone: 800-993-8716
or:        303-393-8716
fax:       303-393-8718



Tue, 16 Mar 1999 03:00:00 GMT  
 Sections Vs. Paragraphs

The EVALUATE verb which I normally use as an equivalent of
IF condition-1
   do something
ELSE
   IF condition-2
      do something else
   ELSE etc.
purely for clarity and ease of both reading and writing and the IF END-IF
construct have eliminated most of the uses that I might have had for GO TO.
I also thaink that I have seen some actual studies done on the issue.  The new
standard will eliminate most of the other areas where GO TO was an effective
if dangerous tool.  Optimizing compilers that do tricks like move paragraphs in
line to replace the PERFORM verb to minimize overhead also make some of the
stunts I played unnecessary (something for which generations of maintenance
programmers not yet hired should be very grateful).


Quote:

>>I'm not sure why, twenty-plus years after the structured programming theories
>>were proven, people still hang onto the idea that there are situations when
>a GO
>   Exactly when, how, and by whom was this "proof" published?  As I was
>around twenty-plus years ago, I can state with perfect confidence that
>Djikstra & Co. ASSERTED that GOTO-less code was "the way", and then a lot
>of people jumped on the bandwagon and repeated the assertion, and then
>another generation of programmers came along and were taught the same
>thing, and, being human, believed what they were told and so propagated
>the myth.  Why was there a bandwagon?  Somebody else published a study at
>about the same time that "established" that comments improved code quality
>and maintainability as much as did GOTO-less programming, but it got
>little attention because comments were less exciting academically.  And
>there, essentially, the matter remains.  It's noticeable that people who
>disparage GOTO's have not, as a general rule, tried them systematically.
>(Note also that "structured" does NOT equal "GOTO-less", but that's a
>different matter).  If anyone wishes to challenge me I will send them a
>real-world, quite simple problem which they can take the GOTO's out of,
>and, if they're right, they'll be able to convince me that by MY
>standards, the result is better.

>>clear, clean code.  EVALUATE, as a true case structure, is also very
> worthwhile.
>  perhaps you can help me here: in what way is EVALUATE superior to a
>properly-planned string of IF's?  (No contentiousness here: I really would
>like to know).

Clark F. Morris, Jr.

                                                          506-657-9331

                                                           902-665-4006


Tue, 16 Mar 1999 03:00:00 GMT  
 
 [ 76 post ]  Go to page: [1] [2] [3] [4] [5] [6]

 Relevant Pages 

1. Sections vs Paragraphs

2. Sections vs Paragraphs - a CICS programmers perspective.

3. useless discussions (was: sections vs. paragraphs)

4. Paragraphs vs Sections

5. Sections vs. Paragraphs

6. Sections vs. Paragraphs - Challenge - Results

7. Paragraphs vs. Sections - Performance under DEC COBOL/VMS

8. Second paragraph of section 6 of IEEE standard

9. Ending sections/paragraphs

10. (dis)advantages of sections /paragraphs in procedure division?

11. L S 5 $ W K M C Re: Paragraphs or Sections

12. sections and paragraphs ???

 

 
Powered by phpBB® Forum Software