Joshua towers



Yüklə 43,18 Kb.
tarix08.08.2018
ölçüsü43,18 Kb.
#61695

JOSHUA TOWERS

COBOL

CSC 415


Joshua Thomas Ignatius Towers

Dr. Lyle


CSC 415

10/10/2011



History

COBOL was created in a committee over a short period of time much like ALGOL 60. This happened in 1959 when there weren’t many languages for use in the area of business applications. One such language was FLOW-MATIC, which was implemented in 1957, but it was for use with only the UNIVAC computers. This is worth stating because FLOW-MATIC is “the primary progenitor of COBOL” (Sebesta).

In December of 1953 Grace Hopper wrote a proposal that suggested that “Mathematical programs should be written in mathematical notation, data processing programs should be written in English statements” (Sebesta). This proposal would go unheeded, but in 1955 a similar proposal had some hope though it took a prototype system in order to finally convince UNIVAC. This system compiled small programs using English keywords, then French keyword, and then German keywords. This show was the primary factor in UNIVAC’s acceptance of the proposal made by Hopper. May 28 and 29 1959 the Department of Defense sponsored the first meeting for the common language for business applications at the pentagon. The group consensus was that the language should use as much English as possible. In order to broaden the base of those who could program computers the committee decided that the language should be easy to use even at the expense of the power of the language. Making the language both English and easy to use would also allow managers to read programs. Lastly the committee decided that language should not be restricted by any implementation problems. One large concern in the committee was that the universal language needed to be made very quickly because other companies such as RCA and Sylvania were creating their own languages. It was believed that it would be harder for the language to be widely used the longer it took to create the language. Because of this the Short Range Committee was formed. The committee decided to separate the language in to two categories the data description and executable operation but also decided against subscripts because individuals in data processing were uncomfortable with mathematic notation. The final report from this committee was finished December 1959 and described COBOL 60. COBOL 60 was standardized by ANSI in 1968 but revised version where standardized in 1974, 1985, and 2002 (Sebesta).
Results

A lot of concepts where started in COBOL. Such as the DEFINE verb which “was the first high-level language construct for macros” (Sebesta) and the hierarchical data structures or records which were first implemented in COBOL and we cannot forget the long names with connector characters which allowed connotative names. The data description section is the most powerful section of a COBOL program, here you can define a variable to a level of defining the number of decimal digits and defining the implied decimal point. File records are also defined at this level of detail and so are lines to be sent to the printer which make COBOL perfect for printing reports (Sebesta).


Program Structure

The structure of COBOL programs is hierarchical. The different parts of the hierarchy are Divisions, Sections, Paragraphs, Sentences, and Statements. There are four divisions. The first is the Identification Division which contains program information such as the program id and author name. The structure of the Identification Division is as follows:



IDENTIFICATION DIVISION
PROGRAM-ID. NameOfProgram.
[AUTHOR. YourName.]
other entries here (Coughlan)
The second Division is the Environment Division which contains information on the environment in which the program is to be run. “The purpose of the ENVIRONMENT DIVISION is to isolate in one place all aspects of the program that are dependent upon a specific computer, device or encoding sequence” (Coughlan). Next is the Data Division which contains information on all data items the program will process. It contains section such as the file section which describes data sent to and brought from the computer’s peripherals and the working-storage section which contains the definition of all variables in the program. The Data Division’s structure is as follows:

http://www.csis.ul.ie/cobol/course/resources/pics/datadiv.gif (Coughlan)

Last is the Procedure Division which contains the code of the program. (Coughlan) A sample COBOL program is in the Appendix.


Data Types

COBOL has three categories of data types the Numeric, AlphaNumeric, and Alphabetic. The distinction between these data types can be blurred because the compiler will allow non numeric data to be placed in numeric variables unfortunately if this happens and the variable is calculated on this will cause the program to crash. These variables are defined with the PIC or PICTURE clause and then a set amount of symbols such as ‘9’ for numeric ‘X’ for any character ‘A’ for alphabetic ‘V’ for decimal points and ‘S’ for signs. These variables can be assigned values through calculation in the executable operations section of the program or have a literal value set to them. Literals can be either string or numeric. When using a string literal the literal must be surrounded by quotes and when using a numeric literal there are no quotes but only numbers, decimal points , and plus or minus signs may be used. COBOL doesn’t provide for user defined constants though it does provide what are called Figurative Constants. These Figurative Constants can be used at any time that a literal can be. The Figurative Constants are represented by words such as SPACE, representing one or more spaces, and ZERO, representing one or more zeros, though unlike normal literals when these are used they fill the data item. COBOL also supports data item grouping, records, which are declared using level numbers which is to say that data item with higher level numbers are contained by those with lower numbers (Coughlan).


Statement Level Control Structures

COBOL has two main selection structures the if statement and the evaluate statement. The if statement is structured much like that of the Ada if statement starting with if condition then and ending with end-if. The conditional operators in COBOL are much like in other languages you have >, <, and = though not must be spelled out. The evaluate verb is COBOLs version of the switch or case statement. The evaluate structure has the following structure:



EVALUATE condition (ALSO condition)

WHEN value (ALSO value) stateblock

WHEN OTHER stateblock

END-EVALUATE
COBOL’s iteration is in the form of the PERFORM statement the Perform Until which is the while loop and Perform …Varying which is the for loop each of these is closed with the END-PERFORM clause.
Arithmetic

For mathematic functions in COBOL there are the ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE statements. These statements are structured verb value [BY INTO FROM TO] value [GIVING] variable [ROUNDED]. These work be performing the indicated operation on the values around the [BY INTO FROM TO] and placing the value in the variable after the [GIVING] (Coughlan).


Subprograms

COBOL subprograms are different from paragraphs in that paragraphs are any unit of code that can be executed using the PREFORM verb in the PROCEDURE DIVISION of a COBOL program and that all paragraphs are “parameter-less” (McCloskey) and have access to all of the data declared in the DATA DIVISION. On the other hand subprograms are in separate files and are compiled separately from the program that calls them. In order for this to happen you must link the object files of the separately compiled files. This also poses a slight inconvenience in that compilation units cannot access the data items of different compilation units which means that the main program and the subprograms cannot share data like the paragraphs can. Subprograms must instead have parameters passed if they are to use data from and give data back to the main program. The subprograms are called using the CALL statement:

CALL USING (McCloskey)

In the argument-list contains a list of data names and literals that can be passed either by reference with the phrase BY REFERENCE or by value with the phrase BY CONTENT. The data items that are declared in the subprogram are static which means that they maintain their values between calls of the subprogram and the VALUE clause for setting the initial values of declared data items only happens once, but there are two ways to refresh these data items first the CANCEL statement and the INITIAL phrase after the Programs name in the PROGRAM-ID paragraph. COBOL subprograms are significantly like normal COBOL program in structure. They have the identification, environment, data, and procedure divisions, but there are a few differences. First the data division has the file and working storage sections, but it also has the linkage section which allows for the description of the arguments of the subprogram. Second in the procedure division header there is a using clause where the arguments are listed to establish the order that the arguments are to be passed. Last in the main program the statement STOP RUN is used to end the program in a subprogram this would have the same effect. In order to end the subprogram and return to the main program the EXIT PROGRAM statement is used.


Concurrency

Support for concurrency in COBOL revolves around what are called run-units. These run units are comprised of the main program and any subprograms that may be called by it which means that a run-unit can contain many programs or even just one. These run-units can communicate with each other by using libraries of routines. On 16 bit COBOL systems must install certain .dle,.dll, and .dlw file, but in 32 bit systems the support is standard. The run-units are described by the terms Originator or “The first run-unit that makes the call to create a run-unit” (Merant) the Parent or “A run-unit that makes the call to create a run-unit” (Merant) the Child or “The run-unit created from the call made by the parent” (Merant) and the Coru or “The set of run-units containing the originator and all descendant run-unit” (Merant).


Object Orientation

In Object Oriented COBOL the structure of classes is like that of nested programs in that the object and the factory definitions are nested inside of the class definition. Each class can have one factory. These factories contain the definitions for data and methods for the class. The data and methods in the factories can be accessed by any methods in the object methods in the class. Objects on the other hand contain the data and methods the object. Inheritance does exist in COBOL in fact a class can inherit from multiple classes with the Inherits clause. When creating a instance of an object one uses the invoke clause followed by the class name the New reference and the handle for the object.


Error Handling

Exception handling in COBOL is done through the use of Declaratives. Declaratives are defined at the beginning of the PROCEDURE division of a COBOL program in the DECLARATIVES section (IBM). The structure of the Error Declaratives is:

USE AFTER EXCEPTION { exception-name-1 } ... (Reimann, COBOL 2000)

The Exception procedure will be executed:



  • “Either after completing the system-defined input/output error routine.”

  • “Upon recognition of an INVALID KEY or AT END condition when an INVALID KEY or AT END phrase has not been specified in the input/output statement.” (IBM)

After the procedure is performed the execution of the program is returned to the routine that invoked the procedure. For user defined error handling the RAISE statement followed by the name of the Error procedure you wish to invoke is used.
Evaluation

According to “Concepts of Programming Languages” the main criteria for programming language analysis are Readability or how easily the language is understand, Write ability or how easy it is to create the code, Cost how much does it cost for everything involved with the language, and Reliability or does it work correctly



Readability

In the beginning of the development of COBOL the plan was to create a language that was as much like English as possible. This was done by using English verbs, clauses, and sentences. This means that COBOL allows for its programs to be self-documenting which would allow for beginning programmers to not only read and understand COBOL but also to reduce learning time and cost. This similarity to English would also allow for management staff and other non-programmers to read and understand the code being used



Write ability

The design of COBOL was to allow for English keywords. This allows for easily written nearly English statement. This means that both beginning programmers and nonprogrammers would be able to learn to write the code of COBOL easily.



Cost

First we see the fact that COBOL is very readable which makes COBOL a very easily learned language this would lower the cost learning COBOL. Second we see the fact that COBOL is very writeable which leads to the programs being more easily written and thus written faster which lowers the cost of creating the programs. Third we look at the cost of the compilation and implementation of COBOL programs can be expensive do to the cost of the mainframes they normally run on (Towers)



Reliability

The fact that COBOL is still being used after fifty years must give us an indication that COBOL is a reliable language for business applications. The high readability allows for easy maintenance and the write ability allows for the program to be more easily written and thus more likely correct.



Conclusion

I believe that the easily read English structure of COBOL along with the its easily written nature makes COBOL a very good language. On the other hand I recognize that COBOL was created for the purpose of being used for business, and I understand that it would not be as useful as different fuller languages if trying to perform tasks outside of the realm of simple data processing.

Appendix A sample COBOL program

000010 IDENTIFICATION DIVISION.

000020 PROGRAM-ID. SAMPLE.

000030 AUTHOR. J.P.E. HODGSON.

000040 DATE-WRITTEN. 4 February 2000

000041


000042* A sample program just to show the form.

000043* The program copies its input to the output,

000044* and counts the number of records.

000045* At the end this number is printed.

000046

000050 ENVIRONMENT DIVISION.



000060 INPUT-OUTPUT SECTION.

000070 FILE-CONTROL.

000080 SELECT STUDENT-FILE ASSIGN TO SYSIN

000090 ORGANIZATION IS LINE SEQUENTIAL.

000100 SELECT PRINT-FILE ASSIGN TO SYSOUT

000110 ORGANIZATION IS LINE SEQUENTIAL.

000120

000130 DATA DIVISION.



000140 FILE SECTION.

000150 FD STUDENT-FILE

000160 RECORD CONTAINS 43 CHARACTERS

000170 DATA RECORD IS STUDENT-IN.

000180 01 STUDENT-IN PIC X(43).

000190


000200 FD PRINT-FILE

000210 RECORD CONTAINS 80 CHARACTERS

000220 DATA RECORD IS PRINT-LINE.

000230 01 PRINT-LINE PIC X(80).

000240

000250 WORKING-STORAGE SECTION.



000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.

000261 01 RECORDS-WRITTEN PIC 99.

000270

000280 01 DETAIL-LINE.



000290 05 FILLER PIC X(7) VALUE SPACES.

000300 05 RECORD-IMAGE PIC X(43).

000310 05 FILLER PIC X(30) VALUE SPACES.

000311


000312 01 SUMMARY-LINE.

000313 05 FILLER PIC X(7) VALUE SPACES.

000314 05 TOTAL-READ PIC 99.

000315 05 FILLER PIC X VALUE SPACE.

000316 05 FILLER PIC X(17)

000317 VALUE 'Records were read'.

000318 05 FILLER PIC X(53) VALUE SPACES.

000319


000320 PROCEDURE DIVISION.

000321


000330 PREPARE-SENIOR-REPORT.

000340 OPEN INPUT STUDENT-FILE

000350 OUTPUT PRINT-FILE.

000351 MOVE ZERO TO RECORDS-WRITTEN.

000360 READ STUDENT-FILE

000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH

000380 END-READ.

000390 PERFORM PROCESS-RECORDS

000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.

000411 PERFORM PRINT-SUMMARY.

000420 CLOSE STUDENT-FILE

000430 PRINT-FILE.

000440 STOP RUN.

000450


000460 PROCESS-RECORDS.

000470 MOVE STUDENT-IN TO RECORD-IMAGE.

000480 MOVE DETAIL-LINE TO PRINT-LINE.

000490 WRITE PRINT-LINE.

000500 ADD 1 TO RECORDS-WRITTEN.

000510 READ STUDENT-FILE

000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH

000530 END-READ.

000540

000550 PRINT-SUMMARY.



000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.

000570 MOVE SUMMARY-LINE TO PRINT-LINE.

000571 WRITE PRINT-LINE.

000572


000580

(Hodgson)


Appendix B class definition format

Id Division.

Class-Id. class-name-1 Inherits class-name-2 ... .

...


Environment Division.

Configuration Section.

Repository.

Class class-name-3 as "external-class-name-3"

...

Id Division.



Factory.

Environment Division.

...

Data Division.



Working-Storage Section.

...


Procedure Division.

{class methods}

End Factory.

Id Division.

Object.


Environment Division.

Data Division.

...

Procedure Division.



{object methods}

End Object.

End Class class-name-1.

Example 1. Class Definition

Id Division.

Method-Id. method-name-1 ...

...


Data Division.

Working-Storage Section.

...

Linkage Section.



...

Procedure Division [Using ...] [Returning ...] .

...

Invoke object-reference method [Using ...] [Returning ...]



...

Exit method.

End Method method-name-1. (Reimann, Object Oriented Programmin in COBOL 2000)

Bibliography


Coughlan, Michael. Cobol Tutorial. March 1999. October 2011 .

Hodgson, Jonathan. Sample COBOL program. 7 Febuary 2000. .

IBM. "Language Reference Version 3 Release 3." IBM, february 2004.

McCloskey, Robert. COBOL Subprograms. .

Merant. Programmer's Guide to Writing Programs. 1999. .

Reimann, Artur. COBOL 2000. San Jose: Fujitsu Software Corporation, 1999.

—. "Object Oriented Programmin in COBOL 2000." Fujitsu Software Corporation, 1999.

Sebesta, Robert W. Concept of Programming Languages. Boston: Pearson Education, 2009.



Towers, William. Manager Data Storage Joshua Towers. November 2011.


Yüklə 43,18 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə