DEV-6: Advanced Object-Oriented Programming in the ABL Evan Bleicher Senior Development Manager Shelley Chase

Slides:



Advertisements
Similar presentations
METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Advertisements

OpenEdge® Object-oriented ABL
DEV-13: You've Got a Problem, Here’s How to Find It
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Inheritance Polymorphism Briana B. Morrison CSE 1302C Spring 2010.
Session 07: C# OOP 4 Review of: Inheritance and Polymorphism. Static and dynamic type of an object. Abstract Classes. Interfaces. FEN AK - IT:
ITEC200 – Week03 Inheritance and Class Hierarchies.
 In inheritance the child (subclass) chooses its parent (superclass)  Remember - only public or “protected” methods and variables are inherited  Should.
Road Map Introduction to object oriented programming. Classes
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Advanced Object-Oriented Programming Features
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Abstract Classes and Interfaces
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Chapter 8 More Object Concepts
CISC6795: Spring Object-Oriented Programming: Polymorphism.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Object-oriented programming in the Progress® 4GL 10.1A Beta
Object-Oriented Extensions to the 4GL Pat Bonser Product Readiness PUG Norway Lillehammer March 16th & 17th.
DEV-12: Object-oriented Programming in OpenEdge® ABL
ARCH-03: Implementing the OpenEdge™ Reference Architecture – Part 1 John Sadd Progress Fellow and OpenEdge Evangelist.
Object-Oriented Programming and the Progress ABL Tomáš Kučera Principal Solution Engineer / EMEA Power Team.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Inheritance. Introduction Inheritance is one of the cornerstones of object-oriented programming because it allows the creation of hierarchical classifications.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
ARCH-4: The Presentation Layer in the OpenEdge® Reference Architecture Frank Beusenberg Senior Technical Consultant.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
DEV-8: OpenEdge® Architect – Extensibility & Third Party Integration Sunil Belgaonkar Principal Software Engineer Architect Phillip Magnay.
Chapter Eleven Classes and Objects Programming with Microsoft Visual Basic th Edition.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Object Oriented Software Development
AN OBJECT LESSON IN CLASSES “or how OO ABL solves everything.”
ARCH-07: Implementing the OpenEdge™ Reference Architecture – Part 2
ARCH-7: A Class-Based Implementation of the OpenEdge® Reference Architecture John Sadd Fellow and OpenEdge Evangelist Applied Technology.
ARCH-11: Building your Presentation with Classes John Sadd Fellow and OpenEdge Evangelist Sasha Kraljevic Principal TSE.
CS212: Object Oriented Analysis and Design Lecture 17: Virtual Functions.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Object-Oriented Programming Chapter Chapter
Object Oriented Programming
Introduction to Object-Oriented Programming Lesson 2.
ARCH-7: Integrate this! SonicMQ® and the OpenEdge® Reference Architecture Christian Stiller Technical Architect.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Classes, Interfaces and Packages
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
A Survey of Object-Oriented Concept Oscar Nierstrasz.
Peter Judge A8: What’s New in Object-Oriented ABL Principal Software Engineer OpenEdge 10.1C and beyond.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Modern Programming Tools And Techniques-I
Object-Orientated Programming
DEV-12: What’s New in Object-Oriented ABL
DEV-20: Using Classes and Procedures in OpenEdge® 10.1B
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
MOVE-11: Using Classes and Procedures in OpenEdge® 10
Advanced Programming in Java
DEV-08: Exploring Object-oriented Programming
Fundaments of Game Design
Presentation transcript:

DEV-6: Advanced Object-Oriented Programming in the ABL Evan Bleicher Senior Development Manager Shelley Chase Architect

© 2006 Progress Software Corporation2 DEV-6 Advanced Object-oriented Programming in the ABL 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 we are 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

© 2006 Progress Software Corporation3 DEV-6 Advanced Object-oriented Programming in the ABL Agenda  Order Entry System Object Model  Abstract Programming with Classes  Working with Datasets / Temp-tables in Classes  Miscellaneous Topics: Debugging with Classes Using SUPER in Classes Accessing Classes on the AppServer Error Handling policy for Classes Proper Encapsulation in Classes Compiler Tips and Tricks Coding Standards

© 2006 Progress Software Corporation4 DEV-6 Advanced Object-oriented Programming in the ABL Order Entry System Object Model “ Business Entity” Interface between DA layer and Presentation / Integration “Data Access Object” Interface to Data Store Use OpenEdge® Reference Architecture Presentation Business Services Data Access Data Sources Common Infrastructure Enterprise Services

© 2006 Progress Software Corporation5 DEV-6 Advanced Object-oriented Programming in the ABL Order Entry Object Model - Handout Inherits CLASS Acme.BusinessEntity DEF VAR rDataObject AS CLASS IDataAccess METHOD VOID fetchWhere ( ) METHOD VOID saveChanges ( ) CLASS Acme.BEOrder INHERITS Acme.BusinessEntity METHOD VOID processOrder ( ) … Inherits CLASS Acme.BEInternalOrder INHERITS Acme.BEOrder DEF VAR invoiceNum AS INT METHOD VOID OVERRIDE processOrder ( ) … CLASS Acme.BEExternalOrder INHERITS Acme.BEOrder DEF VAR crossDept AS INT METHOD VOID OVERRIDE processOrder ( ) … Inherits CLASS Acme.DAOrderSuper PROTECTED TEMP-TABLE ttOline PROTECTED TEMP-TABLE ttOrder PROTECTED DATASET dsOrder … INTERFACE Acme.IDataAccess METHOD LONGCHAR selectRecords ( … ) Implements CLASS Acme.DAItem IMPLEMENTS Acme.IDataAccess, Acme.IList … CLASS Acme.DAOrder INHERITS Acme.DAOrderSuper IMPLEMENTS Acme.IDataAccess, Acme.IList METHOD LONGCHAR selectRecords ( … ) METHOD NextRecord ( ) METHOD PrevRecord ( ) METHOD VOID postOlineFill ( … ) METHOD VOID postDSFill ( … ) Implements INTERFACE Acme.IList METHOD nextRecord ( ) METHOD prevRecord ( ) …

© 2006 Progress Software Corporation6 DEV-6 Advanced Object-oriented Programming in the ABL Order Entry Object Model – Data Access Layer CLASS Acme.DAOrderSuper CLASS Acme.DAItem INTERFACE Acme.IList Implements CLASS Acme.DAOrder Inherits INTERFACE Acme.IDataAccess Implements Data Access Interface Navigation Interface Super Order Class Specific Order Class Specific Item Class PROTECTED TEMP-TABLE ttOline PROTECTED TEMP-TABLE ttOrder PROTECTED DATASET dsOrder METHOD LONGCHAR selectRecords (…) METHOD LONGCHAR selectRecords (…) METHOD LONGCHAR selectRecords (…) Implements

© 2006 Progress Software Corporation7 DEV-6 Advanced Object-oriented Programming in the ABL Order Entry Object Model – Business Servicing LayerCLASSAcme.BusinessEntity CLASSAcme.BEOrder CLASSAcme.BEInternalOrderCLASSAcme.BEExternalOrder Inherits Business Entity Class Order Class Specific Internal Order Class Specific External Order Class DEF VAR rDataObject AS CLASS Acme.IDataAccess METHOD VOID fetchWhere ( ) METHOD VOID saveChanges ( ) METHOD VOID processOrder( ) METHOD OVERRIDE VOID processOrder ( ) METHOD OVERRIDE VOID processOrder ( )

© 2006 Progress Software Corporation8 DEV-6 Advanced Object-oriented Programming in the ABL Physical Architecture of A Class Hierarchy COMPILE Acme/BEExternalOrder.cls SAVE. Inherits / Acme / BusinessEntity.cls / Acme / BusinessEntity.cls / Acme / BEOrder.cls / Acme / BEOrder.cls / Acme / BEExternalOrder.cls / Acme / BEExternalOrder.cls

© 2006 Progress Software Corporation9 DEV-6 Advanced Object-oriented Programming in the ABL COMPILE Physical Architecture of A Class Hierarchy COMPILE Acme/BEExternalOrder.cls SAVE. Inherits / Acme / BusinessEntity.cls / Acme / BusinessEntity.cls / Acme / BEOrder.cls / Acme / BEOrder.cls / Acme / BEExternalOrder.cls / Acme / BEExternalOrder.cls

© 2006 Progress Software Corporation10 DEV-6 Advanced Object-oriented Programming in the ABL Physical Architecture of A Class Hierarchy COMPILE Acme/BEExternalOrder.cls SAVE. Inherits Digest: Inherits: Implements: … Class r-code Data / Acme / BusinessEntity.cls / Acme / BusinessEntity.cls / Acme / BEOrder.cls / Acme / BEOrder.cls / Acme / BEExternalOrder.cls / Acme / BEExternalOrder.cls / Acme / BEOrder.r 5678 Acme/BusinessEntity, 1234 None / Acme / BusinessEntity.r 1234 None / Acme / BEExternalOrder.r 9000 Acme/BEOrder, 5678 None

© 2006 Progress Software Corporation11 DEV-6 Advanced Object-oriented Programming in the ABL Agenda  Order Entry System Object Model  Abstract Programming with Classes  Working with Datasets / Temp-tables in Classes  Miscellaneous Topics: Debugging with Classes Using SUPER in Classes Accessing Classes on the AppServer Error Handling policy for Classes Proper Encapsulation in Classes Compiler Tips and Tricks Coding Standards

© 2006 Progress Software Corporation12 DEV-6 Advanced Object-oriented Programming in the ABL Abstract (Generic) Programming  Define super class / interface for abstraction Define abstract methods  Use abstract object Define object reference for super class / interface Set object ref to NEW subclass object Polymorphism causes method calls on object ref to run method in subclass  Abstract code should be put in top most class Supports abstraction and reuse

© 2006 Progress Software Corporation13 DEV-6 Advanced Object-oriented Programming in the ABL Choosing between Super Classes and Interfaces  “Both” Define API (contract) for abstract programming Support polymorphism  Super class Contain common code for sharing / augmenting Contain protected data members  Interfaces Use when no common behavior exists Use to emulate multiple inheritance

© 2006 Progress Software Corporation14 DEV-6 Advanced Object-oriented Programming in the ABL Abstract Programming Using Interfaces  Define an interface Common methods put in interface Implementer must provide code for methods INTERFACE Acme.IDataAccess CLASS Acme.DAOrder CLASS Acme.DAItem Implements METHOD LONGCHAR selectRecords (…) METHOD LONGCHAR selectRecords (…) METHOD LONGCHAR selectRecords (…) Interface Implementer

© 2006 Progress Software Corporation15 DEV-6 Advanced Object-oriented Programming in the ABL Abstract Programming Using Super Classes  Define a super class Common methods including code put in super class Optionally, subclass can override common code CLASSAcme.BEOrder CLASSAcme.BEInternalOrderCLASSAcme.BEExternalOrder METHOD OVERRIDE VOID processOrder ( ) METHOD OVERRIDE VOID processOrder ( ) METHOD VOID processOrder ( ) Super Class Subclass

© 2006 Progress Software Corporation16 DEV-6 Advanced Object-oriented Programming in the ABL Abstract Programming Sample CLASS Acme.BusinessEntity: /* Define variable for interface type */ DEFINE PROTECTED VARIABLE rDataObject AS CLASS Acme.IDataAccess NO-UNDO. /* Generic method – works on any class that implements Acme.IDataAccess */ METHOD PUBLIC LONGCHAR fetchWhere (…): lcVar1 = rDataObject:selectRecords (…). … CLASS Acme.BEOrder: CONSTRUCTOR BEOrder ( ): /* Create Order data object assign to super class reference*/ rDataObject = NEW Acme.DAOrder ( ). lcVar2 = rDataObject:fetchWhere (…). …

© 2006 Progress Software Corporation17 DEV-6 Advanced Object-oriented Programming in the ABL Demo of Abstract Programming

© 2006 Progress Software Corporation18 DEV-6 Advanced Object-oriented Programming in the ABL Multiple Inheritance Using Interfaces  Some older OO languages support multiple inheritance  Newer OO languages support multiple APIs using interfaces – class inheritance is single CLASSAcme.DAOrder INTERFACE Acme.IDataAccess INTERFACE Acme.IList Implements METHOD LONGCHAR selectRecords (…) METHOD NextRecord ( ) METHOD PrevRecord ( ) METHOD LONGCHAR selectRecords (…) METHOD NextRecord ( ) METHOD PrevRecord ( )

© 2006 Progress Software Corporation19 DEV-6 Advanced Object-oriented Programming in the ABL Agenda  Order Entry System Object Model  Abstract Programming with Classes  Working with Datasets / Temp-tables in Classes  Miscellaneous Topics: Debugging with Classes Using SUPER in Classes Accessing Classes on the AppServer Error Handling policy for Classes Proper Encapsulation in Classes Compiler Tips and Tricks Coding Standards

© 2006 Progress Software Corporation20 DEV-6 Advanced Object-oriented Programming in the ABL Datasets and Temp-Tables in Classes  Defined in a class as either PROTECTED or PRIVATE – class data member  Passed as parameters to methods (like procs)  Cannot be returned from a method (like UDFs)  Temp-table columns can contain Progress.Lang.Object Automatically upcast when put into column CAST column value to subclass before use

© 2006 Progress Software Corporation21 DEV-6 Advanced Object-oriented Programming in the ABL Using a Class from a Temp-Table Column  Use TYPE-OF function with CAST DEFINE VAR rOrder AS Acme.BEOrder. FOR EACH myTT: /* See if column is an external order */ IF TYPE-OF (myTT.rObj, Acme.BEExternalOrder) THEN rOrder = CAST (myTT.rObj, Acme.BEExternalOrder). /* See if column is an internal order */ ELSE IF TYPE-OF (myTT.rObj, Acme.BEInternalOrder) THEN rOrder = CAST (myTT.rObj, Acme.BEInternalOrder). END.

© 2006 Progress Software Corporation22 DEV-6 Advanced Object-oriented Programming in the ABL Protected DataSets / Temp-Tables  PROTECTED access in subclass “automatic” – use normal syntax Better than passing BY-REFERENCE or BIND, defining as SHARED No need to include definition in subclass CLASS Acme.DAOrderSuper CLASS Acme.DAOrder Inherits PROTECTED TEMP-TABLE ttOline PROTECTED TEMP-TABLE ttOrder PROTECTED DATASET dsOrder FOR EACH ttOrder: DISPLAY ttOrder.CustomerName

© 2006 Progress Software Corporation23 DEV-6 Advanced Object-oriented Programming in the ABL ProDataSet Event Handlers  Callbacks can be methods as well as internal procedures  Protected datasets can have handlers in subclass CLASS Acme. DAOrderSuper CLASS Acme.DAOrder Inherits /* Set callback in subclass for dataset in super class */ hDSOrder = dsOrder:HANDLE. hDSOrder:SET-CALLBACK (“AFTER-FILL”, “postDSFill”). … METHOD VOID postDSFill (DATASET dsOrder). …

© 2006 Progress Software Corporation24 DEV-6 Advanced Object-oriented Programming in the ABL Demo of Datasets and Temp-Tables

© 2006 Progress Software Corporation25 DEV-6 Advanced Object-oriented Programming in the ABL Agenda  Order Entry System Object Model  Abstract Programming with Classes  Working with Datasets / Temp-tables in Classes  Miscellaneous Topics: Debugging with Classes Using SUPER in Classes Accessing Classes on the AppServer Error Handling policy for Classes Proper Encapsulation in Classes Compiler Tips and Tricks Coding Standards

© 2006 Progress Software Corporation26 DEV-6 Advanced Object-oriented Programming in the ABL Debugging Classes  Debugger works with Classes  Demos have been running classes in the debugger Steps into each constructor / destructor in hierarchy Shows polymorphism in action – subclass method is stepped into  Remember Open class file in debugger to see data members

© 2006 Progress Software Corporation27 DEV-6 Advanced Object-oriented Programming in the ABL Using SUPER in Classes  Use SUPER ( ) to call super class constructor Only valid in constructor Must be first line if present  Use SUPER:method-name ( ) to call a method higher in the class hierarchy Valid in constructor, destructor, methods Must specify method-name (unlike procedures)

© 2006 Progress Software Corporation28 DEV-6 Advanced Object-oriented Programming in the ABL AppServer Running with Classes on an AppServer  Option 1: Classes on both client and server –Provide serialize and deserialize methods –Remote class access support coming  Option 2: Dispatch procedure on AppServer –Client interacts with dispatcher –Data passed in temp-table or dataset Remote classes cannot be accessed from client ClientAppServer Data Client Data Dispatch.p RUN dispatch.p SET h. RUN getData (myTT) in h. Dataset / Temp-table Data Dataset / Temp-table Data Dataset / Temp-table

© 2006 Progress Software Corporation29 DEV-6 Advanced Object-oriented Programming in the ABL Error Handling  RETURN ERROR not allowed in classes  Options: 1.Use output parameter or return type 2.Use STOP mechanism  Improved error handling coming!

© 2006 Progress Software Corporation30 DEV-6 Advanced Object-oriented Programming in the ABL Options for Handling Errors in Constructor 1.Constructor handles error –Run DELETE THIS-OBJECT in constructor  Automatically runs destructors for any successful constructors in hierarchy –Caller checks object reference for unknown 3.Use an output parameter to indicate error to caller –Caller must check for error and delete object 2.Compile/Deployment errors found during NEW –Mismatched parameters, super class not found –Automatically aborts new and cleans up –Caller checks object reference for unknown or ERROR-STATUS:ERROR

© 2006 Progress Software Corporation31 DEV-6 Advanced Object-oriented Programming in the ABL Demo of Error Handling in Classes

© 2006 Progress Software Corporation32 DEV-6 Advanced Object-oriented Programming in the ABL Encapsulation  Good practice to keep data members protected or private  Provide “getter” and “setter” routines to access data members Safe access Support read-only or write-only  PROPERTY class members coming!

© 2006 Progress Software Corporation33 DEV-6 Advanced Object-oriented Programming in the ABL Compiling Tips and Techniques  Strong-typing only works if you compile – running “compile-on-the-fly” catches all errors at runtime Be safe – always rebuild/compile your code  Recompiling only super classes can result in runtime errors – always recompile subclasses that depend on super classes to be safe Exceptions to this rule…

© 2006 Progress Software Corporation34 DEV-6 Advanced Object-oriented Programming in the ABL Call new method Recompile Add new method Compile Compiling Tips and Techniques  No recompile of subclasses required when: Methods / data is added to super class Only implementation changes, not signature  When subclass accesses new methods and data, must recompile A BE F K J H GD C I

© 2006 Progress Software Corporation35 DEV-6 Advanced Object-oriented Programming in the ABL Compiling Tips and Techniques  COMPILER: MULTI-COMPILE = TRUE Uses cache to store classes already compiled in session “Cache” cleared when set to FALSE OE Architect uses this option  Otherwise COMPILE builds full class hierarchy – no timestamp check Total files compiled: MULTI-COMPILE = FALSE:25 MULTI-COMPILE = TRUE:8 A B EFHG DC Build procedures (make.p)

© 2006 Progress Software Corporation36 DEV-6 Advanced Object-oriented Programming in the ABL Recommended Coding Standards  Always use packages in your type name: Acme.DAOrder First node is your company name  Class and Interface names use CamelCase starting with uppercase letter Interface names start with leading “I”: Acme.IList  Methods and data member use camelCase with lowercase first letter  Follow rules for encapsulation, abstraction, and delegation

© 2006 Progress Software Corporation37 DEV-6 Advanced Object-oriented Programming in the ABL In Summary  Object-oriented ABL supports standard OO design patterns – abstraction, encapsulation, inheritance, polymorphism  OO functionality still coming Overloading Properties Error handling Remote Objects CLASS-GLOBAL (Static) Strongly-typed events

© 2006 Progress Software Corporation38 DEV-6 Advanced Object-oriented Programming in the ABL Related Sessions  DEV–1: Introduction to Object–Oriented Language Concepts and Programming in OpenEdge ABL  MOVE–11: Using Classes and Procedures in OpenEdge 10

© 2006 Progress Software Corporation39 DEV-6 Advanced Object-oriented Programming in the ABL Questions?

© 2006 Progress Software Corporation40 DEV-6 Advanced Object-oriented Programming in the ABL Thank you for your time

© 2006 Progress Software Corporation41 DEV-6 Advanced Object-oriented Programming in the ABL