+ All Categories
Home > Documents > DEV-10: Object-oriented Language Constructs for the 4GL

DEV-10: Object-oriented Language Constructs for the 4GL

Date post: 04-Jan-2016
Category:
Upload: hiram-griffith
View: 30 times
Download: 0 times
Share this document with a friend
Description:
DEV-10: Object-oriented Language Constructs for the 4GL. Evan Bleicher Development Manager. Under Development. D I S C L A I M E R. D I S C L A I M E R. - PowerPoint PPT Presentation
Popular Tags:
44
DEV-10: Object-oriented Language Constructs for the 4GL Evan Bleicher Development Manager
Transcript
Page 1: DEV-10: Object-oriented Language Constructs for the 4GL

DEV-10:Object-oriented Language Constructs for the 4GL

Evan BleicherDevelopment Manager

Page 2: DEV-10: Object-oriented Language Constructs for the 4GL

2 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

D I S C L A I M E R

Under Development

This talk includes information about potential future products and/or product enhancements.

What I am going to say reflects our current thinking, but the information contained herein is preliminary and subject to change. Any future products we ultimately deliver may be materially different from what is described here.

D I S C L A I M E R

Page 3: DEV-10: Object-oriented Language Constructs for the 4GL

3 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Agenda

OO Overview Anatomy of a

CLASS Objects Inheritance Compiler changes Interoperability

Page 4: DEV-10: Object-oriented Language Constructs for the 4GL

4 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Object-Oriented Overview

Class – Data members and methods

Object – Runtime instance of a class

Object Reference

– Strongly typed object handle

Typing – Type consistency enforced

Interface – Set of method definitions

Page 5: DEV-10: Object-oriented Language Constructs for the 4GL

5 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Object-Oriented OverviewClass: Order

PRIVATE:

orderNum AS INT

CalculatePrice ( )

PROTECTED:

CalculateTax ( )

PUBLIC:

CreateOrder ( )

GetOrderTotal ( )

Inheritance – Reuse and specialize

code

Super Class – Common features

inherited by another class

Subclass – Inherits features from

another class

Override – Derived class

customized behavior

Class: InternalOrder

PUBLIC:

GetOrderTotal ( )

Page 6: DEV-10: Object-oriented Language Constructs for the 4GL

6 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Benefits of OO in the 4GL

Programming Business

1. Productivity2. Easy to develop 3. Maintenance4. Robustness5. Ease of use

1. Code Reuse2. Inheritance 3. Encapsulation4. Strong typing5. Invocation

model

Page 7: DEV-10: Object-oriented Language Constructs for the 4GL

7 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Similarities betweenClasses and Procedures

Classes Procedures

1. Procedure file2. Define variables3. Internal procedures4. User defined functions5. Code in main block6. Super procedures

1. Class files2. Data members3. VOID methods4. Other methods5. Constructor6. Inheritance

Page 8: DEV-10: Object-oriented Language Constructs for the 4GL

8 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Agenda

OO Overview Anatomy of a

CLASS Objects Inheritance Compiler changes Interoperability

Page 9: DEV-10: Object-oriented Language Constructs for the 4GL

9 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Anatomy of a Class

CLASS <class-type>

[options]:

[ <data member> …]

[ <constructor> ]

[ <method> … ]

[ <destructor> ]

END [ CLASS ].

Page 10: DEV-10: Object-oriented Language Constructs for the 4GL

10 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

acme\request\Order.cls

CLASS acme.request.Order:

CLASSStatement

CLASS <class-type>

[ INHERITS <super-class-type> ]

[ IMPLEMENTS <interface-type>

[, <interface-type> ]… ]

[ FINAL ]:

[package.]classname

ProPath

\acme

\request

\Order.cls

\Order.r

Page 11: DEV-10: Object-oriented Language Constructs for the 4GL

11 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

CLASS acme.request.Order:

END CLASS.

Example:Defining a CLASS hierarchy

acme\request\Order.cls

CLASS acme.request.InternalOrder

INHERITS acme.request.Order:

END CLASS.

acme\request\InternalOrder.cls

Page 12: DEV-10: Object-oriented Language Constructs for the 4GL

12 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Data Members

New keyword added to existing DEFINE syntax– PRIVATE (default)

– PROTECTED

– PUBLIC Defined outside of methods Scoped to class Define state an object

Page 13: DEV-10: Object-oriented Language Constructs for the 4GL

13 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Example:Defining Data Members

acme\request\Order.cls

CLASS acme.request.Order:

DEFINE PUBLIC VARIABLE ShipDate AS DATE.

DEFINE PROTECTED TEMP-TABLE SalesRepTT

FIELD RepName AS CHAR

FIELD Region AS CHAR.

DEFINE PRIVATE VARIABLE OrderNum AS INT.

END CLASS.

Page 14: DEV-10: Object-oriented Language Constructs for the 4GL

14 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Anatomy of a Method

METHOD [PRIVATE | PUBLIC | PROTECTED ]

[ FINAL]

{ VOID | <return-type> }

<method-name>

( [ <parameter> [ ,<parameter> ]… ] ):

<method-body>

END [METHOD].

Page 15: DEV-10: Object-oriented Language Constructs for the 4GL

15 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

CLASS acme.request.Order:

DEFINE PRIVATE VARIABLE OrderNum AS INTEGER.

METHOD PUBLIC INTEGER GetOrderNum ( ):

RETURN OrderNum.

END METHOD.

END CLASS.

Example:Defining Methods

acme\request\Order.cls

Page 16: DEV-10: Object-oriented Language Constructs for the 4GL

16 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

CLASS acme.request.Order:

DEFINE PRIVATE VARIABLE OrderNum AS INTEGER.

METHOD PUBLIC VOID SetOrderNum

(INPUT ordNum AS INTEGER ):

OrderNum = ordNum.

END METHOD.

END CLASS.

Example:Defining Methods

acme\request\Order.cls

Page 17: DEV-10: Object-oriented Language Constructs for the 4GL

17 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Anatomy of a Constructor

CONSTRUCTOR [ PUBLIC | PROTECTED]

<class-name>

( [ <parameter> [ ,<parameter> ]… ] ):

<constructor-body>

END [CONSTRUCTOR].

Page 18: DEV-10: Object-oriented Language Constructs for the 4GL

18 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

CLASS acme.request.Order:

CONSTRUCTOR PUBLIC Order ( ) :

/* Initialize data members */

END CONSTRUCTOR.

END CLASS.

Example:Defining Constructor

acme\request\Order.cls

Page 19: DEV-10: Object-oriented Language Constructs for the 4GL

19 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Anatomy of a Destructor

DESTRUCTOR [ PRIVATE ]

<class-name> ( ):

<destructor-body>

END [DESTRUCTOR].

Page 20: DEV-10: Object-oriented Language Constructs for the 4GL

20 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

CLASS acme.request.Order:

DESTRUCTOR PRIVATE Order ( ) :

/* Perform cleanup of resources. */

END DESTRUCTOR.

END CLASS.

Example:Defining Destructor

acme\request\Order.cls

Page 21: DEV-10: Object-oriented Language Constructs for the 4GL

21 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Anatomy of an Interface

INTERFACE <interface-type>:

[ <temp-table> | <ProDataSet> ]

[ <method> …]

END [INTERFACE].

Page 22: DEV-10: Object-oriented Language Constructs for the 4GL

22 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

INTERFACE acme.navigation.support.IList:

METHOD PUBLIC VOID Next ( ).

METHOD PUBLIC VOID Prev ( ).

METHOD PUBLIC VOID First ( ).

METHOD PUBLIC VOID Last ( ).

END INTERFACE.

Example:Defining an Interface

acme\navigation\support\IList.cls

Page 23: DEV-10: Object-oriented Language Constructs for the 4GL

23 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

CLASS acme.request.InternalOrder

INHERITS acme.request.Order

IMPLEMENTS acme.navigation.support.IList:

METHOD PUBLIC VOID Next ( ) :/* Implementation of Next Method */

END METHOD.

/* Repeat for Prev, First and Last … */

END CLASS.

Example:Implementing an Interface

acme\request\InternalOrder.cls

Page 24: DEV-10: Object-oriented Language Constructs for the 4GL

24 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Agenda

OO Overview Anatomy of a

CLASS Objects Inheritance Compiler changes Interoperability

Page 25: DEV-10: Object-oriented Language Constructs for the 4GL

25 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Instantiating an object

NEW statement

Creates an instance of the class

Strongly typed object reference

Causes constructor to be invoked– Execution of all constructors in hierarchy

chain

Page 26: DEV-10: Object-oriented Language Constructs for the 4GL

26 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

NEW Statement

DEFINE VARIABLE <object-ref > AS

[ CLASS ] <class-type>.

<object-ref > = NEW <class-type >

( <parameter> [ ,<parameter> ]… )

[ ON <server-handle> ] [ NO-ERROR ].

Page 27: DEV-10: Object-oriented Language Constructs for the 4GL

27 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

DEFINE VARIABLE rIntOrderObj AS

CLASS acme.request.InternalOrder.

rIntOrderObj =

NEW acme.request.InternalOrder ( ).

Example:Instantiating an Object

Page 28: DEV-10: Object-oriented Language Constructs for the 4GL

28 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Accessing Data Members & Methods

An Object Reference can access– PUBLIC Data Members

– PUBLIC Methods

– rIntOrderObj:shipDate

– rIntOrderObj:GetOrderNum ( )

Page 29: DEV-10: Object-oriented Language Constructs for the 4GL

29 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Accessing Data Members & Methods

Within a class hierarchy– PUBLIC or PROTECTED Data Members– PUBLIC or PROTECTED Methods– SalesRepTT.RepName– protectedMethod ( )

Within a class– PRIVATE Data Members – PRIVATE Methods– orderNum– CalculatePrice ( )

Page 30: DEV-10: Object-oriented Language Constructs for the 4GL

30 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Agenda

OO Overview Anatomy of a

CLASS Objects Inheritance Compiler changes Interoperability

Page 31: DEV-10: Object-oriented Language Constructs for the 4GL

31 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Inheritance

Subclass inherits super class’– PUBLIC & PROTECTED data members– PUBLIC & PROTECTED methods

Subclass can:– add additional capabilities– augment behavior of super class– override behavior of super class

Page 32: DEV-10: Object-oriented Language Constructs for the 4GL

32 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

InternalOrder

Overriding

Order

METHOD VOID GetOrderTotal ( ):

SUPER-CLASS:GetOrderTotal ( ).

END METHOD.

METHOD VOID GetOrderTotal ( ):

END METHOD.

Overridden method must have same signature

To access any super class’ method use SUPER-CLASS:

<method-name>

Always invoke method in most-derived object!

Page 33: DEV-10: Object-oriented Language Constructs for the 4GL

33 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

METHOD PUBLIC DECIMAL GetOrderTotal ( ):

/* Calculate total */

RETURN totalOrder.

END METHOD.

Example:Overriding

acme\request\Order.cls

METHOD PUBLIC DECIMAL GetOrderTotal ( ):

DEFINE VAR dTotal AS DECIMAL.

dTotal = SUPER-CLASS:GetOrderTotal ( ).

RETURN dTotal * dDiscount.

END METHOD.

acme\request\InternalOrder.cls

Page 34: DEV-10: Object-oriented Language Constructs for the 4GL

34 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

InternalOrder

DEFINE VAR rIntOrderObj AS

acme.request.InternalOrder.

rIntOrderObj = NEW

acme.request.InternalOrder ( ).

rIntOrderObj:GetOrderTotal ( ).

Example:Calling Overridden Method

Order

GetOrderTotal:

RETURN SUPER-CLASS:

GetOrderTotal ( ) * discount.

GetOrderTotal:

RETURN total.

Page 35: DEV-10: Object-oriented Language Constructs for the 4GL

35 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Agenda

OO Overview Anatomy of a

CLASS Objects Inheritance Compiler changes Interoperability

Page 36: DEV-10: Object-oriented Language Constructs for the 4GL

36 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Compiler changes

Two – pass compiler Compile time validation of object

reference Validates

– Methods

– Parameters Compiles all files in class hierarchy

Page 37: DEV-10: Object-oriented Language Constructs for the 4GL

37 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Agenda

OO Overview Anatomy of a

CLASS Objects Inheritance Compiler changes Interoperability

Page 38: DEV-10: Object-oriented Language Constructs for the 4GL

38 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

InteroperabilityProcedures and Classes

Procedures – Can NEW a CLASS

– Can DELETE an object

– Invoke methods using object reference

– Can pass object reference as a parameter

Classes– Can RUN a procedure

– Can invoke internal procedure / udf using procedure handle

Page 39: DEV-10: Object-oriented Language Constructs for the 4GL

39 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Integration with tools

New IDE

Procedure Editor

Procedure Window

Debugger

Page 40: DEV-10: Object-oriented Language Constructs for the 4GL

40 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Future

Phased approach

Overloading

Arrays of object references

Available via Open Client

Improved Error Handling

Page 41: DEV-10: Object-oriented Language Constructs for the 4GL

41 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

In Summary

Standard OO concepts available in the 4GL

Built on top of existing 4GL constructs

Interoperability with Procedure / Functions

Page 42: DEV-10: Object-oriented Language Constructs for the 4GL

42 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Questions?

Page 43: DEV-10: Object-oriented Language Constructs for the 4GL

43 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation

Thank you for your time!

Page 44: DEV-10: Object-oriented Language Constructs for the 4GL

44 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation


Recommended