Thông tin tài liệu
&2%2/
Issue 2b, March 2004
REMHFWRULHQWHG
SURJUDPPLQJZLWKFRERO
2EMHFWRULHQ WHG
oppubb.book Page 1 Tuesday, March 16, 2004 12:23 PM
Copyright © 2004 Micro Focus International Limited.
All rights reserved.
Micro Focus International Limited has made every effort to ensure that this book is
correct and accurate, but reserves the right to make changes without notice at its sole
discretion at any time. The software described in this document is supplied under a
license and may be used or copied only in accordance with the terms of such license,
and in particular any warranty of fitness of Micro Focus software products for any
particular purpose is expressly excluded and in no event will Micro Focus be liable for
any consequential loss.
Animator®, COBOL Workbench®, EnterpriseLink®, Mainframe Express®,
Micro Focus®, Net Express®, REQL® and Revolve® are registered trademarks, and
AAI™, Analyzer™, Application to Application Interface™, AddPack™, AppTrack™,
AssetMiner™, CCI™, DataConnect™, Dialog System™, EuroSmart™, FixPack™,
LEVEL II COBOL™, License Management Facility™, License Server™,
Mainframe Access™, Mainframe Manager™, Micro Focus COBOL™, Object COBOL™,
OpenESQL™, Personal COBOL™, Professional COBOL™, Server Express™,
SmartFind™, SmartFind Plus™, SmartFix™, SourceConnect™, Toolbox™, WebSync™,
and Xilerator™ are trademarks of Micro Focus International Limited. All other
trademarks are the property of their respective owners.
No part of this publication, with the exception of the software product user
documentation contained on a CD-ROM, may be copied, photocopied, reproduced,
transmitted, transcribed, or reduced to any electronic medium or machine-readable
form without prior written consent of Micro Focus International Limited.
Licensees may duplicate the software product user documentation contained on a CD-
ROM, but only to the extent necessary to support the users authorized access to the
software under the license agreement. Any reproduction of the documentation,
regardless of whether the documentation is reproduced in whole or in part, must be
accompanied by this copyright statement in its entirety, without modification.
U.S. GOVERNMENT RESTRICTED RIGHTS. It is acknowledged that the Software and the
Documentation were developed at private expense, that no part is in the public
domain, and that the Software and Documentation are Commercial Computer
Software provided with RESTRICTED RIGHTS under Federal Acquisition Regulations
and agency supplements to them. Use, duplication or disclosure by the U.S.
Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of The
Rights in Technical Data and Computer Software clause at DFAR 252.227-7013 et. seq.
or subparagraphs (c)(1) and (2) of the Commercial Computer Software Restricted
Rights at FAR 52.227-19, as applicable. Contractor is Micro Focus, 9420 Key West
Avenue, Rockville, Maryland 20850. Rights are reserved under copyright laws of the
United States with respect to unpublished portions of the Software.
20040316122346
oppubb.book Page 2 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
3
Table of Contents
About this Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Command Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Side Headings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Part 1: Overview
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Object-oriented COBOL syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Developing OO Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
What to Read Next. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Object-oriented Analysis and Design . . . . . . . . . . . . . . . . . . . . . . . . 19
2 OO Programming Concepts . . . . . . . . . . . . . . . . . . . 21
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Polymorphism. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
oppubb.book Page 3 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
4
Part 2: Object-oriented COBOL Programming
3 Using Objects in Programs . . . . . . . . . . . . . . . . . . . . 33
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Declaring Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Using Object References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Declaring Object References . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Manipulating Object References . . . . . . . . . . . . . . . . . . . . . . . . . 36
Object Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Sending Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Using the INVOKE Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Inline Method Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Invocation Using Object Properties . . . . . . . . . . . . . . . . . . . . . . . 40
Conformance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Creating a New Instance Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Destroying Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Object Destruction Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Finalized Object References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Class Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Method Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Data Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Files in OO Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Programming Factory Object Behavior . . . . . . . . . . . . . . . . . . . . . . . 56
Factory Object Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Class Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Factory Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Programming Instance Object Behavior . . . . . . . . . . . . . . . . . . . . . . 58
Instance Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Instance Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Instance Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
oppubb.book Page 4 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
5
Parameterized Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Method Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Predefined Object Reference Names . . . . . . . . . . . . . . . . . . . . . . . . 67
Instance Creation Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Get and Set Property Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
PROPERTY Clause in a Data Item Definition . . . . . . . . . . . . . . . 72
PROPERTY Clause in a Method Definition . . . . . . . . . . . . . . . . . 72
Coding the Object Property Syntax . . . . . . . . . . . . . . . . . . . . . . 73
6 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Interface Source Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Interface Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Parameterized Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7 Compiling and Debugging OO COBOL Applications 81
Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Directly Inherited Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Preventing Reallocation of Object Handles . . . . . . . . . . . . . . . . 84
Finding Memory Leaks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Object Data Guard Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Message Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Troubleshooting Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Memory Exceptions and Protection Violations on Method
Invocations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Symbol Redefined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Program Not Found . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
oppubb.book Page 5 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
6
Part 3: Tutorials
8 Objects and Messages Tutorial. . . . . . . . . . . . . . . . . 95
The Stopwatch Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Sending Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9 Simple Class Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . 101
Structure of a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Identifying a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Identifying Classes Used by a Program . . . . . . . . . . . . . . . . . . . . 102
The Factory Object Source Element . . . . . . . . . . . . . . . . . . . . . . . 103
Factory Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
The Instance Object Source Element . . . . . . . . . . . . . . . . . . . . . . 104
Instance Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Animating the Stopwatch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
10 More Complex Class Tutorial . . . . . . . . . . . . . . . . . . 111
The Personnel Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Exploring the Personnel Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Animating the Personnel Application . . . . . . . . . . . . . . . . . . . . . . . . 114
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
11 Interfaces and Parameterized Class Tutorial . . . . . . 119
The PClass Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Exploring the Pclass Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Animating the Pclass Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
oppubb.book Page 6 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
7
Part 4: Micro Focus OO COBOL Alternatives and
Extensions
12 Micro Focus OO COBOL Alternative Syntax . . . . . . 127
Summary of Syntax Alternatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Shared Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Working-Storage Section in a Method . . . . . . . . . . . . . . . . . . . . . . . 129
Working Storage and Object Storage. . . . . . . . . . . . . . . . . . . . . . . . 129
Data Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Direct Data Inheritance in Source Code . . . . . . . . . . . . . . . . . . . 130
Direct Data Inheritance at Run Time . . . . . . . . . . . . . . . . . . . . . 132
Extending a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
13 Requirements-based Vocabulary . . . . . . . . . . . . . . . 137
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Defining a Vocabulary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
External Class Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Method Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
User-defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Using Vocabulary-defined Verbs and Functions. . . . . . . . . . . . . . . . 141
Part 5: Micro Focus Class Libraries
14 Introduction to the Class Libraries . . . . . . . . . . . . . . 145
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Public and Private Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Class Library Method Parameter Types . . . . . . . . . . . . . . . . . . . . . . . 147
Class Library Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Animating the Class Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
oppubb.book Page 7 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
8
15 Collection Frameworks . . . . . . . . . . . . . . . . . . . . . . . 151
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Different Categories of Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Creating Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Creating Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Working with CharacterArray Objects. . . . . . . . . . . . . . . . . . . . . 156
Creating a CharacterArray Object . . . . . . . . . . . . . . . . . . . . . . . . 156
Querying a CharacterArray Object. . . . . . . . . . . . . . . . . . . . . . . . 157
Comparison Between Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Relative Value of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Hashing Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Display Mechanisms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Using the display Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Display on a Listbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Collection Sort Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Iterator Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
16 Intrinsic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Using Intrinsic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Cloning an Intrinsic Data Class . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Sending a Message to an Intrinsic Data Type . . . . . . . . . . . . . . . 167
Writing New Intrinsic Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Code for an Intrinsic Class Object. . . . . . . . . . . . . . . . . . . . . . . . . 168
Code for an Intrinsic Instance Object. . . . . . . . . . . . . . . . . . . . . . 169
17 Callback Frameworks . . . . . . . . . . . . . . . . . . . . . . . . 173
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Using Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Creating a Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Invoking a Callback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
oppubb.book Page 8 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
9
18 Exception Handling Frameworks . . . . . . . . . . . . . . . 177
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Creating an Error Message File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Registering an Exception Message File. . . . . . . . . . . . . . . . . . . . . . . 179
Raising an Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Providing Your Own Exception Handlers . . . . . . . . . . . . . . . . . . . . . 182
Writing Exception Handler Methods . . . . . . . . . . . . . . . . . . . . . 183
Registering an Object with the Exception Handler . . . . . . . . . . 185
Canceling an Exception Registration . . . . . . . . . . . . . . . . . . . . . 185
Replacing the System Exception Method . . . . . . . . . . . . . . . . . . . . . 185
19 Component Frameworks. . . . . . . . . . . . . . . . . . . . . . 187
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Defining Output Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Defining Input Sockets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Connecting Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Sending Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Part 6: Micro Focus OO COBOL Tutorials
20 Inheritance Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . 197
The Account Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Simple Account Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
21 Collections, Intrinsics and Dictionaries Tutorial. . . . 203
Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Using Intrinsics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Dictionaries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Iterator Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
oppubb.book Page 9 Tuesday, March 16, 2004 12:23 PM
Object-oriented Programming with COBOL
10
22 Exception Handling Tutorial . . . . . . . . . . . . . . . . . . . 215
Raising an Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Registering an Exception Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Writing an Exception Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
23 Requirements-based Vocabulary Tutorial . . . . . . . . 223
Introducing the Vocabulary Example . . . . . . . . . . . . . . . . . . . . . . . . . 223
Using Requirements-based Vocabulary . . . . . . . . . . . . . . . . . . . . . . . 225
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Part 7: Appendices
A Descriptions of OO Run-time Switches . . . . . . . . . . 229
List of Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
oppubb.book Page 10 Tuesday, March 16, 2004 12:23 PM
[...]... Overview Object- oriented Programming with COBOL oppubb.book Page 17 Tuesday, March 16, 2004 12:23 PM 17 1 Introduction This chapter introduces the facilities for object- oriented programming provided in your COBOL system, and explains how to use this book to begin OO programming with COBOL Object- oriented COBOL syntax Your COBOL system enables you to do object- oriented (OO) programming in COBOL, while... 2: Object- oriented COBOL Programming This part contains the following chapters: • Chapter 3, “Using Objects in Programs” • Chapter 4, “Classes” • Chapter 5, “Methods” • Chapter 6, “Interfaces” • Chapter 7, “Compiling and Debugging OO COBOL Applications” Object- oriented Programming with COBOL oppubb.book Page 32 Tuesday, March 16, 2004 12:23 PM 32 Part 2: Object- oriented COBOL Programming Object- oriented. .. Express on Windows Object- oriented Programming with COBOL 13 oppubb.book Page 14 Tuesday, March 16, 2004 12:23 PM 14 About this Book Object- oriented Programming with COBOL oppubb.book Page 15 Tuesday, March 16, 2004 12:23 PM 15 Part 1: Overview This part contains the following chapters: • Chapter 1, “Introduction” • Chapter 2, “OO Programming Concepts” Object- oriented Programming with COBOL oppubb.book... languageindependent courses on OOD and OOA Object- oriented Programming with COBOL oppubb.book Page 21 Tuesday, March 16, 2004 12:23 PM 21 2 OO Programming Concepts This chapter describes the key concepts supported by an objectoriented programming language, and how they are implemented by Micro Focus COBOL Micro Focus COBOL supports the ISO 2002 standard for Object- Oriented COBOL (OO COBOL) and supplies some additional... anObject "message" • Copy an object reference to another For example: set anObject1 to anObject2 • Test whether two object references refer to the same object For example: if anObject1 = anObject2 Micro Focus Extension • Test whether an object reference refers to an object of a particular class For example: if anObject1 instance of ClassA Object- oriented Programming with COBOL ... some books dealing with objectoriented methodologies and technologies Booch, Grady Object- Oriented Design Benjamin/Cummings, 1994 ISBN: 0-8053-0091-0 Jacobson , Ivor Object- Oriented Software Engineering Addison-Wesley, 1992 ISBN: 0-201-54435-0 Object- oriented Programming with COBOL 19 oppubb.book Page 20 Tuesday, March 16, 2004 12:23 PM 20 Chapter 1 Introduction Rumbaugh James Object- Oriented Modeling... Declaring Object References You need to declare data items of type OBJECT REFERENCE to hold handles to any objects you will be using For example: 01 01 01 01 anObject usage object reference secdObject usage object reference factory of BankAccount thirdObject usage object reference active-class fourthObject usage object reference Rentable The first line defines an untyped or universal object reference Object- oriented. .. the message draw to any graphical object, without caring what type it is The receiver of the message will execute its own draw method, producing the correct result (see Figure 2-6) Object- oriented Programming with COBOL 29 oppubb.book Page 30 Tuesday, March 16, 2004 12:23 PM 30 Chapter 2 OO Programming Concepts Figure 2-6 Polymorphism Object- oriented Programming with COBOL oppubb.book Page 31 Tuesday,... COBOL Alternative Syntax, in Part 4 Object- oriented Programming with COBOL oppubb.book Page 18 Tuesday, March 16, 2004 12:23 PM 18 Chapter 1 Introduction Developing OO Programs Development starts with the analysis of the problem and the design of a program or programs that solve the problem Object- oriented design involves identifying the objects that you want to work with and what they need to do Object- oriented. .. the instance objects it requires For each instance object created, you must declare an object reference to hold the object handle, although you may overwrite the object handle in an object reference with a new one if you have finished with it When a program has finished with an object, it should destroy it Declaring Classes If you want to use an object in a program, you must declare the object s class . to
begin OO programming with COBOL.
Object- oriented COBOL syntax
Your COBOL system enables you to do object- oriented (OO)
programming in COBOL, while. 12:23 PM
Object- oriented Programming with COBOL
11
About this Book
This book explains how to do object- oriented programming in COBOL,
using ISO 2002 COBOL,
Ngày đăng: 12/02/2014, 23:20
Xem thêm: Tài liệu Object Oriented Programming With Cobol pptx, Tài liệu Object Oriented Programming With Cobol pptx