DEV-10:Object-oriented Language Constructs for the 4GL
Evan BleicherDevelopment Manager
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
3 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Agenda
OO Overview Anatomy of a
CLASS Objects Inheritance Compiler changes Interoperability
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
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 ( )
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
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
8 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Agenda
OO Overview Anatomy of a
CLASS Objects Inheritance Compiler changes Interoperability
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 ].
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
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
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
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.
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].
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
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
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].
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
19 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Anatomy of a Destructor
DESTRUCTOR [ PRIVATE ]
<class-name> ( ):
<destructor-body>
END [DESTRUCTOR].
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
21 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Anatomy of an Interface
INTERFACE <interface-type>:
[ <temp-table> | <ProDataSet> ]
[ <method> …]
END [INTERFACE].
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
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
24 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Agenda
OO Overview Anatomy of a
CLASS Objects Inheritance Compiler changes Interoperability
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
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 ].
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
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 ( )
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 ( )
30 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Agenda
OO Overview Anatomy of a
CLASS Objects Inheritance Compiler changes Interoperability
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
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!
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
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.
35 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Agenda
OO Overview Anatomy of a
CLASS Objects Inheritance Compiler changes Interoperability
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
37 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Agenda
OO Overview Anatomy of a
CLASS Objects Inheritance Compiler changes Interoperability
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
39 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Integration with tools
New IDE
Procedure Editor
Procedure Window
Debugger
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
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
42 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Questions?
43 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Thank you for your time!
44 DEV-10, Object-oriented 4GL Constructs© 2005 Progress Software Corporation
Top Related