Sections vs Paragraphs 
Author Message
 Sections vs Paragraphs

I have watched the different views of your all regarding use of sections in
cobol.

It has been very interesting reading, and I am somewhat surprised that it
appears most do not want them, although apparently depending of which
country one belong to.

However, noone seems to vote yes to the use of sections due to improve the
readability of the program.

There was one gentleman briefly mentioning it, although he preferred to call
sub programs rather than breaking down a single program in sections.

I myself, being programming cobol and Pascal for several years and later
delhpi and C prefer the breakdown into sections. I do this because I may
then easily look back to old code and, in most cases, I know what it does,
where it starts and where it ends in no time. If using paragraphs, this
could be a tedious task.

This view of mine, may of course rely on the fact that I learned pascal
before cobol, and as such were well into "sectioning" my programs. Although
paragraphs has its benefits, I feel that this option is of more bad than
good

Thanks,



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

> I have watched the different views of your all regarding use of sections in
> cobol.

> It has been very interesting reading, and I am somewhat surprised that it
> appears most do not want them, although apparently depending of which
> country one belong to.

> However, noone seems to vote yes to the use of sections due to improve the
> readability of the program.

> There was one gentleman briefly mentioning it, although he preferred to call
> sub programs rather than breaking down a single program in sections.

> I myself, being programming cobol and pascal for several years and later
> delhpi and C prefer the breakdown into sections. I do this because I may
> then easily look back to old code and, in most cases, I know what it does,
> where it starts and where it ends in no time. If using paragraphs, this
> could be a tedious task.

> This view of mine, may of course rely on the fact that I learned pascal
> before cobol, and as such were well into "sectioning" my programs. Although
> paragraphs has its benefits, I feel that this option is of more bad than
> good

> Thanks,

Probably because it's just as easy to read a paragraph as it is to read
a section.  In a structured, program without dropping through, there is
no difference in readability between paragraphs and sections.  The only
people advocating dropping through from one paragraph to another are
those who have the second paragraph being only an EXIT paragraph.

The only advantage of SECTIONS I have seen (in modern programming), is
if your environment mandates one SECTION.  This occurs in copies, IDMS
copies, and in older compilers SORTs.  This is a valid advantage.

If you don't drop between paragraphs, and you don't drop between
sections, how is one more readable than the other?



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs
If you are looking at using SECTIONS to "encapsulate" portions of your code
(for readability and/or maintainability) you *might* want to look at nested
programs - which were introduced in the '85 Standard. Personally, I don't
use them much - but I think they would really interest those who are used to
using SECTIONS for putting "logic" where it belongs.

Note: With some compilers nested programs have severe performance problems -
with others they do not.  You would want to check this out before changing
your own programming paradigm

--
Bill Klein
    wmklein at ix dot netcom dot com

Quote:

>I have watched the different views of your all regarding use of sections in
>cobol.

>It has been very interesting reading, and I am somewhat surprised that it
>appears most do not want them, although apparently depending of which
>country one belong to.

>However, noone seems to vote yes to the use of sections due to improve the
>readability of the program.

>There was one gentleman briefly mentioning it, although he preferred to
call
>sub programs rather than breaking down a single program in sections.

>I myself, being programming cobol and pascal for several years and later
>delhpi and C prefer the breakdown into sections. I do this because I may
>then easily look back to old code and, in most cases, I know what it does,
>where it starts and where it ends in no time. If using paragraphs, this
>could be a tedious task.

>This view of mine, may of course rely on the fact that I learned pascal
>before cobol, and as such were well into "sectioning" my programs. Although
>paragraphs has its benefits, I feel that this option is of more bad than
>good

>Thanks,



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

>The only advantage of SECTIONS I have seen (in modern programming), is
>if your environment mandates one SECTION.  This occurs in copies, IDMS
>copies, and in older compilers SORTs.  This is a valid advantage.

Well. I tend to break down in sub routines to keep each section as small as
possible, thus readable and preferably reusable. Like this:

PROCEDURE DIVISION.
MAIN SECTION.
    PERFORM INIT-PROGRAM.
    PERFORM CORE-FUNCTIONS.
    PERFORM CLEAN-UP.
MAIN-EXIT.
    EXIT.

INIT-PROGRAM SECTION.
INIT-PROGRAM-001.
    PERFORM INIT-VARIABLES.
    PERFORM SETUP-SCREEN.
    PERFORM OPEN-FILES.
INIT-PROGRAM-900.
INIT-PROGRAM-EXIT.
    EXIT.

This nesting, although implying a lot more writing, thus inefficient. Makes
the program extremely well readable. It is my opinion that this is a pre
when your program is becoming more than a 100 lines. I have made programs of
2000+ lines using this structure, and it is always easy to look back into
it.

Quote:
>If you don't drop between paragraphs, and you don't drop between
>sections, how is one more readable than the other?

I agree with you here, I do however find it too easy to be tempted to do
things like:
    PERFORM paragraph THRU paragraph
and
    paragraph-1
        do some stuff
        IF something
            GO TO paragraph-2

In both cases you will not have a strictly limited scope which is easily
read.



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:
>This nesting, although implying a lot more writing, thus inefficient. Makes
>the program extremely well readable. It is my opinion that this is a pre
>when your program is becoming more than a 100 lines. I have made programs
of
>2000+ lines using this structure, and it is always easy to look back into

Sorry, I lost a '1', it should be 12000+ not 200+.

Cheesle



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:


> >The only advantage of SECTIONS I have seen (in modern programming), is
> >if your environment mandates one SECTION.  This occurs in copies, IDMS
> >copies, and in older compilers SORTs.  This is a valid advantage.

> Well. I tend to break down in sub routines to keep each section as small as
> possible, thus readable and preferably reusable. Like this:

> PROCEDURE DIVISION.
> MAIN SECTION.
>     PERFORM INIT-PROGRAM.
>     PERFORM CORE-FUNCTIONS.
>     PERFORM CLEAN-UP.
> MAIN-EXIT.
>     EXIT.

> INIT-PROGRAM SECTION.
> INIT-PROGRAM-001.
>     PERFORM INIT-VARIABLES.
>     PERFORM SETUP-SCREEN.
>     PERFORM OPEN-FILES.
> INIT-PROGRAM-900.
> INIT-PROGRAM-EXIT.
>     EXIT.

> This nesting, although implying a lot more writing, thus inefficient. Makes
> the program extremely well readable. It is my opinion that this is a pre
> when your program is becoming more than a 100 lines. I have made programs of
> 2000+ lines using this structure, and it is always easy to look back into
> it.

I do the exact same thing...  Without sections and exits.  I don't see
how adding the word SECTION makes it more readable.

Quote:
> >If you don't drop between paragraphs, and you don't drop between
> >sections, how is one more readable than the other?

> I agree with you here, I do however find it too easy to be tempted to do
> things like:
>     PERFORM paragraph THRU paragraph
> and
>     paragraph-1
>         do some stuff
>         IF something
>             GO TO paragraph-2

> In both cases you will not have a strictly limited scope which is easily
> read.

I've done too much maintenance to be tempted to do that.


Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs


Quote:
>I have watched the different views of your all regarding use of sections in
>cobol.

>It has been very interesting reading, and I am somewhat surprised that it
>appears most do not want them, although apparently depending of which
>country one belong to.

>However, noone seems to vote yes to the use of sections due to improve the
>readability of the program.

[...]

I vote for the use of sections for the above reason.

In addition, since I am still writing for the IBM System/36 platform,
absolutely need sections so I can construct overlays when I get
near to the partition size limit (PAIN to the max!).

I do sometimes call major functions via a dynamic call mechanism
which puts the subroutine in another partition.

Within a program my rules are

 - each individual major thru minor function is contained in a
   separate section

 - the main section is named A00-name, major functions are named
   Bnn-name, intermediate Cnn-name, lower still Dnn-name, etc

 - paragraphs are never performed

 - PERFORM THRU is never used

I also think this organization enhances the maintainability of the
program.

An exception to the TRHU restriction is when a sort has multiple
sources of input

           SORT SORTI-FILE ASCENDING KEY SORTI-KEY
               INPUT  PROCEDURE IS
                       B19I-OPEN-BALANCES THRU B22I-INVOICE
               OUTPUT PROCEDURE IS B23I-REPORT.

but the input routines are themselves sections.

Kindrick



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

>I do the exact same thing...  Without sections and exits.  I don't see
>how adding the word SECTION makes it more readable.

You are right in that there is no significant differnce so far, however, the
final EXIT statement inevitably terminate it and, at the same time
documenting it. On the other side, one is free to implement a GO TO jump
into another section's paragraph's, so...

I do however prefer it, possibly because of the demand of a body structure
one have in pascal (BEGIN END) and C ({ }). I have never really understood
why it is not demanded in COBOL.

When first comparing to pascal and C, another two features I have been
missing in cobol is local variables (local to sections) and that sections
had the oportunity to be passed parameters. I know one may accomplish this
using separate programs, I do however feel that this would not be the same.
Sort of taste I suppose.

Quote:
>I've done too much maintenance to be tempted to do that.

You're right, however, rookies may not think that way, with disastrous
results without guidance :-)

Cheesle



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

>If you are looking at using SECTIONS to "encapsulate" portions of your code
>(for readability and/or maintainability) you *might* want to look at nested
>programs - which were introduced in the '85 Standard. Personally, I don't
>use them much - but I think they would really interest those who are used
to
>using SECTIONS for putting "logic" where it belongs.

As I mentioned in my other message here, this is absolutely an option, in
particular to get the features of parameter passing and local variables. The
downside of this however being that one may get a huge number of files.
Thus, rapidly causing an administration issue of it.

Quote:
>Note: With some compilers nested programs have severe performance
problems -
>with others they do not.  You would want to check this out before changing
>your own programming paradigm

Performance is one issue, another is that file/record locked conditions may
raise unless one know what one is doing.

Cheesle



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

>>However, noone seems to vote yes to the use of sections due to improve the
>>readability of the program.
>[...]

>I vote for the use of sections for the above reason.

Horray! Then we are two :-)

Quote:
>In addition, since I am still writing for the IBM System/36 platform,
>absolutely need sections so I can construct overlays when I get
>near to the partition size limit (PAIN to the max!).

You have my sympathy, I did once have the problem myself using MS Cobol 2.

Quote:
> - each individual major thru minor function is contained in a
>   separate section
> - the main section is named A00-name, major functions are named
>   Bnn-name, intermediate Cnn-name, lower still Dnn-name, etc

> - paragraphs are never performed

> - PERFORM THRU is never used

>I also think this organization enhances the maintainability of the
>program.

This is way the same strategy I use, a typical layout for me would be;

MYSECT SECTION.
MYSECT-001.
MYSECT-nnn.
MYSECT-900.
MYSECT-EXIT.
    EXIT.

Where 001 and EXIT is used to be unique identifiers for start and end of the
section.
Any need for extra paragraphs is matched with nnn. (Preferably avoided).
An GO TO exit would always be the MYSECT-900, such that I may easily jump to
the end of the section with a search for MYSECT-EXIT.

Cheesle



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

> I do however prefer it, possibly because of the demand of a body structure
> one have in pascal (BEGIN END) and C ({ }). I have never really understood
> why it is not demanded in COBOL.

That's why I would like some way to enforce the standard that every
paragraph structure was terminated by the end of a paragraph.  No drop
throughs.  Then you know where the terminator is.

Quote:
> When first comparing to pascal and C, another two features I have been
> missing in cobol is local variables (local to sections) and that sections
> had the oportunity to be passed parameters. I know one may accomplish this
> using separate programs, I do however feel that this would not be the same.
> Sort of taste I suppose.

Ahhh, that makes sense, you're thinking in C.  At one time mainframe
COBOL programmers had to worry about memory segmentation.  Now very few
COBOL programmers need to think that way.  And we don't think of
paragraphs or sections as being computer functions the way C programmers
do.  It's a subtle distinction.  Now someone brought up on OO would
probably think sub programs more than you or I would.


Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:

>I myself, being programming cobol and pascal for several years and later
>delhpi and C prefer the breakdown into sections. I do this because I may
>then easily look back to old code and, in most cases, I know what it does,
>where it starts and where it ends in no time. If using paragraphs, this
>could be a tedious task.

Yes, but then the way I code, every routine starts with a paragraph name,
and ends on the next paragraph name.  Always.  No exceptions. In the
extremely rare case that I would use a GO TO, then there is only one place
it *can* go.  That is to the head of the paragraph.


Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs

Quote:
>documenting it. On the other side, one is free to implement a GO TO jump
>into another section's paragraph's, so...

You gave yourself away here. GO TO statements are not used nor needed in
structured programming. You obviously are allowing for an unstructured
structure to exist in your programs.

You can get the same readability with paragraphs:
PROCEDURE DIVISION.
0000-MAIN.
    PERFORM INIT-PROGRAM.
    PERFORM CORE-FUNCTIONS.
    PERFORM CLEAN-UP.
    GOBACK
    STOP RUN
0000-MAIN-EXIT.
    EXIT.

INIT-PROGRAM.
    PERFORM INIT-VARIABLES.
    PERFORM SETUP-SCREEN.
    PERFORM OPEN-FILES.
INIT-PROGRAM-EXIT.
    EXIT.

Notice the STOP RUN and GOBACK they are specified in most COBOL programs as
the actual program terminator. Only one of these is necessary. GOBACK is
usually safer than STOP RUN although less descriptive of its function.

The EXIT paragraphs are not needed unless you want them for readability.

What I was told in school was that SECTIONS were necessary for exception
processing. I have only used it for this in school, never in the field.

Don't allow for GO TO's and they won't be used and you'll save yourself some
headaches in the long run.



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs
Someone finally hit on the first and in my opinion ONLY reason to use
sections. Segmentation or overlay due to memory limitations. All the rest is
mis use of this feature I feel.

Warren Simmons

Quote:



>>I have watched the different views of your all regarding use of sections
in
>>cobol.

>>It has been very interesting reading, and I am somewhat surprised that it
>>appears most do not want them, although apparently depending of which
>>country one belong to.

>>However, noone seems to vote yes to the use of sections due to improve the
>>readability of the program.
>[...]

>I vote for the use of sections for the above reason.

>In addition, since I am still writing for the IBM System/36 platform,
>absolutely need sections so I can construct overlays when I get
>near to the partition size limit (PAIN to the max!).

>I do sometimes call major functions via a dynamic call mechanism
>which puts the subroutine in another partition.

>Within a program my rules are

> - each individual major thru minor function is contained in a
>   separate section

> - the main section is named A00-name, major functions are named
>   Bnn-name, intermediate Cnn-name, lower still Dnn-name, etc

> - paragraphs are never performed

> - PERFORM THRU is never used

>I also think this organization enhances the maintainability of the
>program.

>An exception to the TRHU restriction is when a sort has multiple
>sources of input

>           SORT SORTI-FILE ASCENDING KEY SORTI-KEY
>               INPUT  PROCEDURE IS
>                       B19I-OPEN-BALANCES THRU B22I-INVOICE
>               OUTPUT PROCEDURE IS B23I-REPORT.

>but the input routines are themselves sections.

>Kindrick



Tue, 25 Sep 2001 03:00:00 GMT  
 Sections vs Paragraphs


Quote:
>Well. I tend to break down in sub routines to keep each section as small as
>possible, thus readable and preferably reusable. Like this:

>PROCEDURE DIVISION.
>MAIN SECTION.
>    PERFORM INIT-PROGRAM.
>    PERFORM CORE-FUNCTIONS.
>    PERFORM CLEAN-UP.
>MAIN-EXIT.
>    EXIT.

>INIT-PROGRAM SECTION.
>INIT-PROGRAM-001.
>    PERFORM INIT-VARIABLES.
>    PERFORM SETUP-SCREEN.
>    PERFORM OPEN-FILES.
>INIT-PROGRAM-900.
>INIT-PROGRAM-EXIT.
>    EXIT.

Compare:

PROCEDURE DIVISION.
MAIN.
    PERFORM INIT-PROGRAM.
    PERFORM CORE-FUNCTIONS.
    PERFORM CLEAN-UP.
    STOP RUN.
INIT-PROGRAM.
    PERFORM INIT-VARIABLES.
    PERFORM SETUP-SCREEN.
    PERFORM OPEN-FILES.

Same thing!



Tue, 25 Sep 2001 03:00:00 GMT  
 
 [ 125 post ]  Go to page: [1] [2] [3] [4] [5] [6] [7] [8] [9]

 Relevant Pages 

1. Sections vs Paragraphs - a CICS programmers perspective.

2. Sections Vs. Paragraphs

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