Object-Oriented COBOL & Modern Extensions

COBOL Intermediate/Advanced

Chapter 8 · Object-Oriented COBOL & Modern Extensions

Every real program across both courses so far has been procedural — divisions, paragraphs, CALL. A real, genuinely significant turning point arrived decades after COBOL's own 1959 origin: COBOL 2002 added object-oriented syntax and free-format source together, in the same single revision.

A Real, Traceable Turning Point

Work on object-oriented COBOL began in the early 1990s, with real features drawn directly from C++ and Smalltalk, finally approved and published in late 2002 — driven substantially by a genuine, practical need: real interoperability with newer platforms like .NET and Java.

CLASS-ID & METHOD-ID: A Real Class Definition

A real COBOL class lives in its own source, headed by CLASS-ID instead of PROGRAM-ID. Reworking Fundamentals' own BALCHECK subprogram as a genuine method shows the real shape:

IDENTIFICATION DIVISION. CLASS-ID. CUSTOMER-VALIDATOR. OBJECT. METHOD-ID. IS-VALID-BALANCE. DATA DIVISION. LINKAGE SECTION. 01 LS-BALANCE PIC S9(7)V99. 01 LS-RESULT PIC X(1). PROCEDURE DIVISION USING LS-BALANCE LS-RESULT. IF LS-BALANCE < 0 MOVE "N" TO LS-RESULT ELSE MOVE "Y" TO LS-RESULT END-IF. END METHOD IS-VALID-BALANCE. END OBJECT. END CLASS CUSTOMER-VALIDATOR.

The real logic inside IS-VALID-BALANCE is identical to Fundamentals' own BALCHECK — the genuine change is structural: a method now belongs to a real class, callable on a real object, rather than existing as a standalone subprogram.

INVOKE: The Real OO Counterpart to CALL

INVOKE genuinely acts like Chapter 9's own CALL, but targets a real method on a real object instead of a standalone program:

INVOKE VALIDATOR-OBJ "IS-VALID-BALANCE" USING WS-BALANCE WS-RESULT.

A real, genuine shorthand also exists for inline invocation — calling a method directly as part of an ordinary statement, without a separate INVOKE:

MOVE VALIDATOR-OBJ::"IS-VALID-BALANCE" TO WS-RESULT.

INHERITS: Real Class Inheritance

A real subclass genuinely extends an existing class with a plain INHERITS clause on its own CLASS-ID line:

CLASS-ID. PREMIUM-CUSTOMER-VALIDATOR INHERITS CUSTOMER-VALIDATOR.

Free-Format Source: A Genuine Departure

The same real 2002 revision that added object orientation also introduced free-format code — real COBOL that no longer has to respect the strict, punch-card-era column positions every earlier chapter's own examples have implicitly followed. Free-format lines can genuinely start in any column at all, matching the visual style of newer languages.

XML & JSON: Real, Later Data-Interchange Extensions

Genuinely Real, Added Later Still Real XML processing capability was addressed through Technical Reports published between 2003 and 2009, extending COBOL well past its own 2002 object-oriented milestone. Real JSON handling arrived as a later addition still, in the same broad spirit — letting a COBOL program genuinely produce and consume the data formats modern web-facing systems actually expect, without abandoning the language entirely.

Hands-On Exercises

Exercise 1

Using this chapter's own real CUSTOMER-VALIDATOR example and Fundamentals' own Chapter 9 material, explain in your own words what genuinely changed and what genuinely stayed the same between BALCHECK as a standalone subprogram and IS-VALID-BALANCE as a class method.

📄 View solution
Exercise 2

Using this chapter's own real material, explain in your own words why PREMIUM-CUSTOMER-VALIDATOR INHERITS CUSTOMER-VALIDATOR genuinely gives the new class access to IS-VALID-BALANCE without that method needing to be rewritten or copied into the new class at all.

📄 View solution
Exercise 3

Using this chapter's own real material, explain in your own words why object orientation, free-format source, and later XML/JSON support are each described as genuinely separate real additions to COBOL, layered on at different points, rather than one single unified redesign of the language.

📄 View solution

Chapter 8 Quick Reference

  • CLASS-ID / METHOD-ID — real class and method definitions, introduced in COBOL 2002, drawing on C++ and Smalltalk
  • INVOKE object "method" USING ... — the real OO counterpart to Chapter 9's own CALL
  • object::"method" — a real, genuine inline shorthand for method invocation
  • INHERITS — real class inheritance on a CLASS-ID line
  • Free-format source — real column-position freedom, added in the same 2002 revision
  • XML/JSON — real, later interchange extensions (XML via Technical Reports 2003-2009) letting COBOL talk to modern web-facing systems