1 / 44

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

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.

Download Presentation

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

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. DEV-10:Object-oriented Language Constructs for the 4GL Evan Bleicher Development Manager

  2. Under Development D I S C L A I M E R D I S C L A I M E R • 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. DEV-10, Object-oriented 4GL Constructs

  3. Agenda • OO Overview • Anatomy of a CLASS • Objects • Inheritance • Compiler changes • Interoperability DEV-10, Object-oriented 4GL Constructs

  4. 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 DEV-10, Object-oriented 4GL Constructs

  5. Object-Oriented Overview • 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: Order PRIVATE: orderNum AS INT CalculatePrice ( ) PROTECTED: CalculateTax ( ) PUBLIC: CreateOrder ( ) GetOrderTotal ( ) Class: InternalOrder PUBLIC: GetOrderTotal ( ) DEV-10, Object-oriented 4GL Constructs

  6. Benefits of OO in the 4GL Programming Business • Code Reuse • Inheritance • Encapsulation • Strong typing • Invocation model • Productivity • Easy to develop • Maintenance • Robustness • Ease of use DEV-10, Object-oriented 4GL Constructs

  7. Similarities betweenClasses and Procedures Classes Procedures • Procedure file • Define variables • Internal procedures • User defined functions • Code in main block • Super procedures • Class files • Data members • VOID methods • Other methods • Constructor • Inheritance DEV-10, Object-oriented 4GL Constructs

  8. Agenda • OO Overview • Anatomy of a CLASS • Objects • Inheritance • Compiler changes • Interoperability DEV-10, Object-oriented 4GL Constructs

  9. Anatomy of a Class CLASS <class-type> [options]: [ <data member> …] [ <constructor> ] [ <method> … ] [ <destructor> ] END [ CLASS ]. DEV-10, Object-oriented 4GL Constructs

  10. CLASSStatement [package.]classname ProPath \acme \request \Order.cls \Order.r CLASS <class-type> [ INHERITS <super-class-type> ] [ IMPLEMENTS <interface-type> [, <interface-type> ]… ] [ FINAL ]: acme\request\Order.cls CLASS acme.request.Order: DEV-10, Object-oriented 4GL Constructs

  11. Example:Defining a CLASS hierarchy acme\request\Order.cls CLASS acme.request.Order: END CLASS. acme\request\InternalOrder.cls CLASS acme.request.InternalOrder INHERITS acme.request.Order: END CLASS. DEV-10, Object-oriented 4GL Constructs

  12. Data Members • New keyword added to existing DEFINE syntax • PRIVATE(default) • PROTECTED • PUBLIC • Defined outside of methods • Scoped to class • Define state an object DEV-10, Object-oriented 4GL Constructs

  13. 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. DEV-10, Object-oriented 4GL Constructs

  14. Anatomy of a Method METHOD [PRIVATE | PUBLIC | PROTECTED ] [ FINAL] { VOID | <return-type> } <method-name> ( [ <parameter> [ ,<parameter> ]… ] ): <method-body> END [METHOD]. DEV-10, Object-oriented 4GL Constructs

  15. Example:Defining Methods acme\request\Order.cls CLASS acme.request.Order: DEFINE PRIVATE VARIABLE OrderNum AS INTEGER. METHOD PUBLIC INTEGER GetOrderNum ( ): RETURN OrderNum. END METHOD. END CLASS. DEV-10, Object-oriented 4GL Constructs

  16. Example:Defining Methods acme\request\Order.cls CLASS acme.request.Order: DEFINE PRIVATE VARIABLE OrderNum AS INTEGER. METHOD PUBLIC VOID SetOrderNum (INPUT ordNum AS INTEGER ): OrderNum = ordNum. END METHOD. END CLASS. DEV-10, Object-oriented 4GL Constructs

  17. Anatomy of a Constructor CONSTRUCTOR [ PUBLIC | PROTECTED] <class-name> ( [ <parameter> [ ,<parameter> ]… ] ): <constructor-body> END [CONSTRUCTOR]. DEV-10, Object-oriented 4GL Constructs

  18. Example:Defining Constructor acme\request\Order.cls CLASS acme.request.Order: CONSTRUCTOR PUBLIC Order ( ) : /* Initialize data members */ END CONSTRUCTOR. END CLASS. DEV-10, Object-oriented 4GL Constructs

  19. Anatomy of a Destructor DESTRUCTOR [ PRIVATE ] <class-name> ( ): <destructor-body> END [DESTRUCTOR]. DEV-10, Object-oriented 4GL Constructs

  20. Example:Defining Destructor acme\request\Order.cls CLASS acme.request.Order: DESTRUCTOR PRIVATE Order ( ) : /* Perform cleanup of resources. */ END DESTRUCTOR. END CLASS. DEV-10, Object-oriented 4GL Constructs

  21. Anatomy of an Interface INTERFACE <interface-type>: [ <temp-table> | <ProDataSet> ] [ <method> …] END [INTERFACE]. DEV-10, Object-oriented 4GL Constructs

  22. Example:Defining an Interface acme\navigation\support\IList.cls INTERFACE acme.navigation.support.IList: METHOD PUBLIC VOID Next ( ). METHOD PUBLIC VOID Prev ( ). METHOD PUBLIC VOID First ( ). METHOD PUBLIC VOID Last ( ). END INTERFACE. DEV-10, Object-oriented 4GL Constructs

  23. Example:Implementing an Interface 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. acme\request\InternalOrder.cls DEV-10, Object-oriented 4GL Constructs

  24. Agenda • OO Overview • Anatomy of a CLASS • Objects • Inheritance • Compiler changes • Interoperability DEV-10, Object-oriented 4GL Constructs

  25. 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 DEV-10, Object-oriented 4GL Constructs

  26. NEW Statement DEFINE VARIABLE <object-ref > AS [ CLASS ] <class-type>. <object-ref > = NEW <class-type > ( <parameter> [ ,<parameter> ]… ) [ ON <server-handle> ] [ NO-ERROR ]. DEV-10, Object-oriented 4GL Constructs

  27. Example:Instantiating an Object DEFINE VARIABLE rIntOrderObj AS CLASS acme.request.InternalOrder. rIntOrderObj = NEW acme.request.InternalOrder ( ). DEV-10, Object-oriented 4GL Constructs

  28. Accessing Data Members & Methods • An Object Reference can access • PUBLIC Data Members • PUBLIC Methods • rIntOrderObj:shipDate • rIntOrderObj:GetOrderNum ( ) DEV-10, Object-oriented 4GL Constructs

  29. 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 ( ) DEV-10, Object-oriented 4GL Constructs

  30. Agenda • OO Overview • Anatomy of a CLASS • Objects • Inheritance • Compiler changes • Interoperability DEV-10, Object-oriented 4GL Constructs

  31. 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 DEV-10, Object-oriented 4GL Constructs

  32. Overriding Order • Overridden method must have same signature • To access any super class’ method use SUPER-CLASS: <method-name> • Always invoke method in most-derived object! METHOD VOID GetOrderTotal ( ): END METHOD. InternalOrder METHOD VOID GetOrderTotal ( ): SUPER-CLASS:GetOrderTotal ( ). END METHOD. DEV-10, Object-oriented 4GL Constructs

  33. Example:Overriding METHOD PUBLIC DECIMAL GetOrderTotal ( ): /* Calculate total */ RETURN totalOrder. END METHOD. acme\request\Order.cls acme\request\InternalOrder.cls METHOD PUBLIC DECIMAL GetOrderTotal ( ): DEFINE VAR dTotal AS DECIMAL. dTotal = SUPER-CLASS:GetOrderTotal ( ). RETURN dTotal * dDiscount. END METHOD. DEV-10, Object-oriented 4GL Constructs

  34. Example:Calling Overridden Method DEFINE VAR rIntOrderObj AS acme.request.InternalOrder. rIntOrderObj = NEW acme.request.InternalOrder ( ). rIntOrderObj:GetOrderTotal ( ). Order GetOrderTotal: RETURN total. InternalOrder GetOrderTotal: RETURN SUPER-CLASS: GetOrderTotal ( ) * discount. DEV-10, Object-oriented 4GL Constructs

  35. Agenda • OO Overview • Anatomy of a CLASS • Objects • Inheritance • Compiler changes • Interoperability DEV-10, Object-oriented 4GL Constructs

  36. Compiler changes • Two – pass compiler • Compile time validation of object reference • Validates • Methods • Parameters • Compiles all files in class hierarchy DEV-10, Object-oriented 4GL Constructs

  37. Agenda • OO Overview • Anatomy of a CLASS • Objects • Inheritance • Compiler changes • Interoperability DEV-10, Object-oriented 4GL Constructs

  38. 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 DEV-10, Object-oriented 4GL Constructs

  39. Integration with tools • New IDE • Procedure Editor • Procedure Window • Debugger DEV-10, Object-oriented 4GL Constructs

  40. Future • Phased approach • Overloading • Arrays of object references • Available via Open Client • Improved Error Handling DEV-10, Object-oriented 4GL Constructs

  41. In Summary • Standard OO concepts available in the 4GL • Built on top of existing 4GL constructs • Interoperability with Procedure / Functions DEV-10, Object-oriented 4GL Constructs

  42. Questions? DEV-10, Object-oriented 4GL Constructs

  43. Thank you for your time! DEV-10, Object-oriented 4GL Constructs

  44. DEV-10, Object-oriented 4GL Constructs

More Related