1 / 13

Object Oriented COBOL

Object Oriented COBOL. Terminology. Objects replace files & programs “an entity that has a unique identity, specific data values, and specific behaviors or program code” - COBOL 2000 standard Messages communication between objects Method

jacqui
Download Presentation

Object Oriented COBOL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented COBOL

  2. Terminology • Objects • replace files & programs • “an entity that has a unique identity, specific data values, and specific behaviors or program code” - COBOL 2000 standard • Messages • communication between objects • Method • “procedural code that defines a specific function…A method may be thought of as a module or a subroutine” - COBOL 2000 standard • Invoking a method • when one object requests another object to perform a method • Class • a generic definition of an object • Instance • a specific occurrence of an object

  3. TERMINOLOGY • A SUBCLASS uses the attributes (data) and methods of its SUPERCLASS • INHERITANCE - attributes, methods, and relationships from a SUPERCLASS are inherited by its SUBCLASS • Persistence - remembering an object’s previous state

  4. Classes and Instance A customer is represented by an instance Sue Smith 12334 Sommset Customer CHANGE-ADDRESS CUSTOMER NameAddress CHANGE-ADDRESS All Customers are represented by a CLASS

  5. SUPERCLASSES AND SUBCLASSES SUPERCLASS SUBCLASS

  6. INHERITANCE AND POLYMORHISM

  7. CLASSES by FUNCTION • Problem Domain - These classes do the primary work of the system. • UI Classes - Handle such things as the interactive screens to communicate with the user and report printing or other external documents • System Interaction provides interfaces to other systems. Handling files passed between systems, corporate Database access, and telecommunications • Data Management - manage the storage and retrieval of data used by the Problem Domain • Drivers - used to initiate and test objects. May be temporary in nature

  8. Table 20.1 Student-Look-Up System Design Driver & Classes CLASS CATEGORY FUNCTIONS Student-Look-Up Driver Initiates the system and creates the Registrar object. Registrar Problem Domain Maintains overall control of the system, creates the utility objects: StudentUI, StudentDM, and StudentPRT. Interacts with Student to get the student name. Student Problem Domain Maintains the Student data. Can produce the student’s name, credit hours taken, and major. Person Problem Domain Parent Class to Student. Maintains the student name information. StudentDM Data Management Controls the processing of the Student File and creates Student Instances based on requested parameters. StudentPRT User Interface Controls the production of the report. StudentUI User Interface Controls the interactive dialog with the user of the system.

  9. 1 StudentUI GetParametersDisplayHoursRequest DisplayMajorRequest 1 1 1 Person Name GetName PopulateName Registrar ProcessRequests StudentPRT OpenPrinterWriteHeaderWriteDetailFinalizeReport 1-n ‘Contains” symbol 1 StudentDM GetStudentCreateStudentReadRecord Student StudentMajorHoursCompleted PopulateStudent 1 ‘Inheritance’ symbol 1 1 n Student-Look-Up System Design

  10. Structured Little reuse Concerned with files Focus is on Verbs PRINT CHECKS UPDATE PAYROLL Elaborate control structures No data change authorization OO Programming Optimum reuse Objects communicate Messages Focus on the entities Employees Departments Simple structures Data access Control Structured vs OO Programming

  11. COBOL Changes • OBJECT SECTION - part of the ENIVIRONMENT DIVISION and defines the interfaces to CLASSES used by the program • CLASS-CONTROL paragraph - relates the classes use to the class template files. Template files contain the definitions and are linked to the program or class when it is compiled. • Object Reference - a new data type used to store the address (pointer) to objects used by the program. Referred to as handles. • INVOKE - similar to CALL but passes control to the OBJECT it addresses. May pass parameters to or from the invoked procedure.

  12. Figure 20.3 Syntax of INVOKE INVOKE object-name { literal-1 | data-name-1 } [ USING { data-name-2 } … [ RETURNING data-name-3 ] ]

  13. MEMORY Leakage • Occurs when a new instance’s address replaces an previous instance - caused by using the same handle • Original instance remains in memory with no way to access - it has become an orphan • Some OO languages provide for garbage collection - COBO 20XX standard • Destroy unneeded instances INVOKE identifier-1 ‘FINALIZE’ RETURNING identifier-1

More Related