The following specific structured programming practices are suggested:
COBOL Tools for Structured Programming
VS COBOL II offers several language elements that help support a structured approach in your Procedure Division coding:
The case structure is implemented in VS COBOL II by the EVALUATE statement. For example:
In the EVALUATE statement, expressions to be tested are called selection subjects. In the example above, CARPOOL-SIZE is the selection-subject. The answer selected is called a selection-object. When evaluated, each pair of selection-subjects and selection-objects must belong to the same class (numeric, character, CONDITION TRUE or FALSE). Use the EVALUATE statement to select from a set of processing actions. Using EVALUATE, you specify a condition to be evaluated and select a processing action based on that evaluation. You can specify up to 255 evaluate subjects and objects in an EVALUATE statement. There is no limit to the number of WHEN clauses that can be specified in an EVALUATE statement, but one page is a practical limit to observe.
The preceding example of the EVALUATE statement shows that when several conditions evaluate to a range of values and each condition leads to the same processing action, you can use the THRU phrase to easily implement this logic. Alternatively, you can also use multiple WHEN statements when several conditions lead to the same processing action. Multiple WHEN statements give you more flexibility for specifying the same processing action for conditions that do not evaluate to values that fall within a range or evaluate to alphanumeric values, as shown in the following example:
Beginning with the first WHEN phrase, the WHEN phrases are tested in the order they are coded. Therefore, you should order these phrases for optimum performance. The WHEN phrase containing selection-objects that is most likely to be satisfied should be coded first. Code the other WHEN phrases in descending order of probability of satisfaction-except the WHEN OTHER phrase, which must come last. The execution of the EVALUATE statement ends once:
In-Line PERFORM Statement
The traditional out-of-line PERFORM statement requires an implicit branch o a separate paragraph and an implicit return. If the performed paragraph is in the subsequent sequential flow, it will be executed one more time. To avoid this additional execution, the paragraph is placed outside the normal sequential flow. The performed paragraph can be thought of as an internal subroutine.
In structured programming, using an in-line PERFORM statement, the paragraph performs one logical function. For readability, this paragraph should be contained on one listing page (approximately 50 lines or less). The subject of an in-line PERFORM must be an imperative statement. Therefore, statements other than imperative statements within an in-line PERFORM must be coded with their scope terminators. The choice of whether to put a PERFORM statement in-line or out-of-line depends on several factors:
TEST BEFORE or TEST AFTER Loop
The traditional COBOL PERFORM statement allowed just one type of test. The condition to terminate the 'DO LOOP' was always tested before the loop was entered. If the test condition was false, the loop was not executed even once. (In structured programming terminology, this was a 'DO-WHILE' loop.) Because you can now use the TEST BEFORE or TEST AFTER phrase with the PERFORM statement, you can choose to have your test either before the loop entry or after it. With TEST AFTER, the loop is executed the first time-regardless of the condition. TEST BEFORE corresponds to 'DO-WHILE' while TEST AFTER corresponds to 'DO-UNTIL.'
COBOL Tools for Top-Down Coding
The following tools are available to encourage top-down coding:
IBM Mainframe Related Interview Questions
|IBM Lotus Notes Interview Questions||IBM-CICS Interview Questions|
|COBOL Interview Questions||Linux Interview Questions|
|IBM-JCL Interview Questions||IBM Mainframe Interview Questions|
|IBM AIX Interview Questions||IBM WAS Administration Interview Questions|
|IBM Lotus Domino Interview Questions||IBM Integration Bus Interview Questions|
|Mainframe DB2 Interview Questions||Unix Production Support Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.