DEV-12: What’s New in Object-Oriented ABL

Slides:



Advertisements
Similar presentations
OpenEdge® Object-oriented ABL
Advertisements

Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
A5: Structured Error Handling in the ABL Phillip Malone Senior Technical Support Engineer.
DEV-13: You've Got a Problem, Here’s How to Find It
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
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++
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Review of C++ Programming Part II Sheng-Fang Huang.
OOP Languages: Java vs C++
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
DEV-12: Object-oriented Programming in OpenEdge® ABL
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Object Oriented Programming with C++/ Session 6 / 1 of 44 Multiple Inheritance and Polymorphism Session 6.
Catch Me If You Can P ractical Structured Error Handling Peter van Dam.
Programming in Java CSCI-2220 Object Oriented Programming.
Object Oriented Software Development
AN OBJECT LESSON IN CLASSES “or how OO ABL solves everything.”
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
ARCH-11: Building your Presentation with Classes John Sadd Fellow and OpenEdge Evangelist Sasha Kraljevic Principal TSE.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
DEV-6: Advanced Object-Oriented Programming in the ABL Evan Bleicher Senior Development Manager Shelley Chase
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Introduction to Object-Oriented Programming Lesson 2.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Classes, Interfaces and Packages
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Peter Judge A8: What’s New in Object-Oriented ABL Principal Software Engineer OpenEdge 10.1C and beyond.
Object-Oriented Programming: Classes and Objects.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Introduction to Object-oriented Programming
Principles of programming languages 10: Object oriented languages
Topic: Classes and Objects
Data Abstraction: The Walls
Objects as a programming concept
Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes
CIS 200 Test 01 Review.
Andy Wang Object Oriented Programming in C++ COP 3330
DEV-25: You've Got a Problem, Here’s How to Find It
Java Primer 1: Types, Classes and Operators
Polymorphism.
Review: Two Programming Paradigms
About the Presentations
Object Oriented Programming in Java
Object-Orientated Programming
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Indexer AKEEL AHMED.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Inheritance Often, software encapsulates multiple concepts for which some attributes/behaviors overlap E.g. A computer (role-playing) game has: Monsters:
DEV-20: Using Classes and Procedures in OpenEdge® 10.1B
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Java Programming Language
DEV-4: Structured Error Handling in the ABL
MOVE-11: Using Classes and Procedures in OpenEdge® 10
Exception Handling Chapter 9 Edited by JJ.
More Object-Oriented Programming
Classes and Objects.
DEV-08: Exploring Object-oriented Programming
Tonga Institute of Higher Education
Delivering great hardware solutions for Windows
Presentation transcript:

DEV-12: What’s New in Object-Oriented ABL OpenEdge 10.1C and beyond With 10.1A Progress introduced support for object-oriented programming in the OpenEdge ABL. As part of its continued development 10.1C included additional Object-oriented ABL features that ABL developers have come to expect from a flexible, modern language. This session will describe support for statically defined members of a class, which will allow a class to maintain data, and methods that act on it, for the class as a whole rather than for an individual instance of a class. This now enables native support for a singleton object. It will also introduce features such as syntax to work with classes dynamically and support for character to longchar data widening between methods. Shelley Chase OpenEdge Architect

Agenda Overview of Object-oriented ABL 10.1C Features Futures Static behavior and data Dynamic programming Error handling Data widening, NEW function, reserved keywords, THIS-OBJECT Futures DEV-12 What’s New in the Object-Oriented ABL

What is Object-oriented ABL… OpenEdge 10.1 Releases Functionality centered around objects Classes encapsulate data and behavior Properties and variables Methods, constructors and destructor Inheritance shares common behavior Interfaces publish a common API Objects are the runtime instance of a class Strong-typing does compile time validation Can be combined with procedures DEV-12 What’s New in the Object-Oriented ABL

Benefits of Procedural and OO Programming OpenEdge is committed to both programming models Procedures and Classes Modular programming Supports reuse of common behavior (super) Maps well to OpenEdge Reference Architecture Classes only Programming errors caught early by compiler Natural integration with modeling tools and other Object-oriented platforms like .NET™ Modern programming model (used at most universities) DEV-12 What’s New in the Object-Oriented ABL

Agenda Overview of Object-oriented ABL 10.1C Features Futures Static behavior and data Dynamic programming Error handling Data widening, NEW function, reserved keywords, THIS-OBJECT Futures DEV-12 What’s New in the Object-Oriented ABL

Wouldn’t It Be Great If… Classes supported global variables within a session? You could always get a reference to the same object every time you wanted to… without keeping track of anything? … Static Class Members DEV-12 What’s New in the Object-Oriented ABL

A Step Back: Instance Data Separate copy of data for each instance Always need to NEW an object to access members Unique data segment for each instance MyClass Data Data Data Data OpenEdge Runtime DEV-12 What’s New in the Object-Oriented ABL

Instance Data Count = 1 CLASS MyClass: Name = Joe CLASS MyClass: … DEFINE PUBLIC PROPERTY Count AS INT GET. SET. DEFINE PUBLIC PROPERTY Name AS CHARACTER CONSTRUCTOR MyClass ( inName AS CHARACTER ): Name = inName. Count = Count + 1. END CONSTRUCTOR. END CLASS. DEF VAR myClassRef AS CLASS MyClass. myClassRef = NEW CLASS MyClass( “Joe” ). DELETE OBJECT myClassRef. myClassRef = NEW CLASS MyClass( “Tim” ). myClassRef = NEW CLASS MyClass( “Ann” ). Count = 1 Name = Tim Count = 1 Name = Ann DEV-12 What’s New in the Object-Oriented ABL

Classes and Static Data One copy of data for the session Access to static members do not require a NEW object One global data segment MyClass Static Data Static Data Static Data Static Data OpenEdge Runtime DEV-12 What’s New in the Object-Oriented ABL

Static Data Count = 3 Name = Ann Count = 2 Name = Tim Count = 1 Name = Joe CLASS MyClass: … DEFINE PUBLIC STATIC PROPERTY Count AS INT GET. SET. DEFINE PUBLIC STATIC PROPERTY Name AS CHARACTER CONSTRUCTOR MyClass ( inName AS CHARACTER ): Name = inName. Count = Count + 1. END CONSTRUCTOR END CLASS. MyClass:Count = MyClass:Count + 1. MyClass:Name = “Joe”. MyClass:Name = “Tim”. MyClass:Name = “Ann”. DEV-12 What’s New in the Object-Oriented ABL

Classes are not Static… Mix of instance and static members allowed Static members accessed using class type name Instance members accessed using object reference Unqualified references allowed inside class Static members created before instances Static constructor runs before instances

ABL Static Data – “Typed” Global Data Definition of static properties and data members Useful for session-wide data Variables, buffers, temp-tables, queries, datasets, data sources Available anywhere in the session Single instance life-cycle controlled by the AVM Access using class type name DEFINE PUBLIC STATIC PROPERTY Count AS INT GET. SET. MESSAGE MyClass:Count. DEV-12 What’s New in the Object-Oriented ABL

ABL Static Constructor Definition of static constructor Useful to initialize static data Only one static constructor per class No arguments or access mode Can access STATIC data of the class Can RUN procedures Can NEW classes (even this one!) Run automatically before any class member access is allowed CONSTRUCTOR STATIC MyClass ( ): Count = 0. /* Initialize static counter */ END. DEV-12 What’s New in the Object-Oriented ABL

ABL Static Methods Definition of static methods Useful when instance data is not required Can access STATIC data of the class Can RUN procedures Can NEW classes (even this one!) Available anywhere in the session Access using class type name METHOD STATIC PUBLIC INT DisplayMessage( c AS CHAR ): MESSAGE c VIEW-AS ALERT-BOX. END. MyClass:DisplayMessage( “Statics are cool” ). DEV-12 What’s New in the Object-Oriented ABL

Accessing a Static Class Member /* MyClass class not instantiated */ MESSAGE MyClass:Count VIEW-AS ALERT-BOX. Access static data member Count Runtime checks if static class members are loaded; it’s not so MyClass DEV-12 What’s New in the Object-Oriented ABL

Accessing a Static Class Member /* MyClass class not instantiated */ MESSAGE MyClass:Count VIEW-AS ALERT-BOX. Access static data member Count Runtime checks if static class members are loaded; it’s not so Creates static global data segment ttUsers and Count MyClass STATIC ttUsers Count DEV-12 What’s New in the Object-Oriented ABL

Accessing a Static Class Member /* MyClass class not instantiated */ MESSAGE MyClass:Count VIEW-AS ALERT-BOX. Access static data member Count Runtime checks if static class members are loaded; it’s not so Creates static global data segment ttUsers and Count Runs static constructor Initialize Count and ttUsers MyClass STATIC ttUsers = … Count = 0 Joe, 3 Tim, 2 Ann, 5 DEV-12 What’s New in the Object-Oriented ABL

Accessing a Static Class Member /* MyClass class not instantiated */ MESSAGE MyClass:Count VIEW-AS ALERT-BOX. Access static data member Count Runtime checks if static class members are loaded; it’s not so Creates static global data segment ttUsers and Count Runs static constructor Initialize Count and ttUsers Gets value of Count MyClass STATIC ttUsers = … Count = 0 DEV-12 What’s New in the Object-Oriented ABL

New’ing a Class with Static Members DEFINE VAR objRef AS MyClass. objRef = NEW CLASS MyClass( “Joe” ). MyClass NEW an instance of MyClass Runtime checks if static class members are loaded; it is. STATIC ttUsers = … Count = 0 DEV-12 What’s New in the Object-Oriented ABL

New’ing a Class with Static Members DEFINE VAR objRef AS MyClass. objRef = NEW CLASS MyClass( “Joe” ). MyClass NEW an instance of MyClass Runtime checks if static class members are loaded; it is. Creates local data segment name STATIC ttUsers = … Count = 0 Instance name DEV-12 What’s New in the Object-Oriented ABL

New’ing a Class with Static Members DEFINE VAR objRef AS MyClass. objRef = NEW CLASS MyClass( “Joe” ). MyClass NEW an instance of MyClass Runtime checks if static class members are loaded; it is. Creates local data segment name Runs instance constructor Sets instance data name Increments static data Count STATIC ttUsers = … Count = 1 Instance name = Joe DEV-12 What’s New in the Object-Oriented ABL

New’ing a Class with Static Members DEFINE VAR objRef AS MyClass. objRef = NEW CLASS MyClass( “Joe” ). MyClass NEW an instance of MyClass Runtime checks if static class members are loaded; it is. Creates local data segment name Runs instance constructor Sets instance data name Increments static data Count Assigns new instance to object reference STATIC ttUsers = … Count = 1 Instance name = Joe DEV-12 What’s New in the Object-Oriented ABL

New’ing a Class with Static Members DEFINE VAR objRef2 AS MyClass. objRef2 = NEW CLASS MyClass( “Tim” ). MyClass NEW an instance of MyClass Runtime checks if static class members are loaded; it is. Creates local data segment name Runs instance constructor Sets instance data name Increments static data Count Assigns new instance to object reference STATIC ttUsers = … Count = 2 Instance name = Joe Instance name = Tim DEV-12 What’s New in the Object-Oriented ABL

New’ing a Class with Static Members DEFINE VAR objRef3 AS MyClass. objRef3 = NEW CLASS MyClass( “Ann” ). MyClass NEW an instance of MyClass Runtime checks if static class members are loaded; it is. Creates local data segment name Runs instance constructor Sets instance data name Increments static data Count Assigns new instance to object reference STATIC ttUsers = … Count = 3 Instance name = Joe Instance name = Tim Instance name = Ann DEV-12 What’s New in the Object-Oriented ABL

Singleton Design Pattern Single instance of the class Available from anywhere within the session Loaded on demand Singleton Class Instance Data members Avoids any restrictions on static data Private or protected constructor Single instance created on demand Used to return an object reference to a single instance of the class DEV-12 What’s New in the Object-Oriented ABL

Demo – Singleton Class DEV-12 What’s New in the Object-Oriented ABL

Developing with STATIC Members Static lifecycle controlled by OpenEdge Runtime Static class members loaded for the life of the session When a .cls file is changed and re-compiled, the static portion is NOT refreshed Caution during development One active session shared by application and development environment Recompile does not reload any static changes Runtime error for mismatches can occur Session must be restarted DEV-12 What’s New in the Object-Oriented ABL

Developing with STATIC Members Static lifecycle controlled by OpenEdge Runtime Static class members loaded for the life of the session When a .cls file is changed and re-compiled, the static portion is NOT refreshed Caution during development One active session shared by application and development environment Recompile does not reload any static changes Runtime error for mismatches can occur Session must be restarted Use Architect Launch Configurations DEV-12 What’s New in the Object-Oriented ABL 28

Wouldn’t It Be Great If… You could create an instance of a class passing in a character expression for the class type name at runtime? … DYNAMIC-NEW and DYNAMIC-CAST DEV-12 What’s New in the Object-Oriented ABL

Dynamic Programming in OO ABL OO Strong-typing restricts dynamic programming DYNAMIC-NEW New a class using a character expression and it’s constructor parameters Object reference is normally a super class DYNAMIC-CAST Cast an object reference to a type using a character expression Full Progress.Lang.Class reflection API still on roadmap DEV-12 What’s New in the Object-Oriented ABL

Dynamic Object Creation DYNAMIC-NEW Used to create a new instance Fully qualified character type name USING is not used Common parameter list Returns a strongly-typed object Type checked at runtime BusinessEntity BEEmployee BECustomer METHOD BusinessEntity CreateBE( beType AS CHAR): DEFINE VARIABLE myObj AS BusinessEntity. myObj = DYNAMIC-NEW STRING(“BE” + beType)(parm1, …). RETURN myObj. END METHOD. “BE” + beType DEV-12 What’s New in the Object-Oriented ABL

Dynamic Object Casting DYNAMIC-CAST Used to cast an object reference Fully qualified character type name USING is not used Returns a strongly-typed object Type checked at runtime BusinessEntity BEEmployee BECustomer METHOD BusinessEntity CreateBE( beType AS CHAR): DEFINE VARIABLE myObj AS BusinessEntity. myObj = DYNAMIC-NEW STRING(“BE” + beType)(parm1, …). DYNAMIC-CAST( myObj,STRING(“BE” + beType). RETURN myObj. END METHOD. “BE” + beType “BE” + beType DEV-12 What’s New in the Object-Oriented ABL

ClassFactory Design Pattern Class returns different types of classes Available from anywhere within the session Alternative is a large CASE statement ClassFactory Class Creates different classes Common super class for all classes Common set of constructor parameters Type name passed in at runtime DEV-12 What’s New in the Object-Oriented ABL

Demo – Class Factory DEV-12 What’s New in the Object-Oriented ABL

Wouldn’t It Be Great If… ABL had a common way to deal with all errors (system and application)? An error could be thrown out of the local block / procedure and handled elsewhere? … Structured Error Handling DEV-12 What’s New in the Object-Oriented ABL

Structured Error Handling TRY – CATCH model Based on new built-in error objects Uses existing ABL blocks: DO, REPEAT, … System and application errors treated equally Can be used in classes and procedures Fully integrated with existing error handling NO-ERROR ERROR-STATUS RETURN ERROR DEV-12 What’s New in the Object-Oriented ABL

Error Object Hierarchy Progress.Lang.Object The OO portion of the talk – object hierarchy makes all this possible! Every object has as its root PLO Interface (makes it possible to catch errors that are not OpenEdge errors) (more applicable with .NET) PLP is the root of built-in error objects PLE is all system generated errors – errors raised by the AVM, OpenEdge runtime (FIND fails) PLA is any error your application requires – raised by the programmer Any error you define! What does it mean to catch different kinds of errors? SysError – all system generated errors AppError – all errors raised by the applications (or distinguish and catch specific user-defined types) ProError – catches all errors – then CAST to get to specific error info. interface – catches all errors as well, including third party errors that implement the interface, such as System.Exception Progress.Lang. Error <<interface>> Progress.Lang.ProError Application Errors System Errors Progress.Lang. AppError Progress.Lang. SysError User-Defined Error Objects Progress.Lang. SoapFaultError DEV-12 What’s New in the Object-Oriented ABL

Error Handling Example: System Error CATCH put on existing FOR EACH block… FOR EACH Customer: FIND Order 1000. /* Fails */ MESSAGE "Never reach here". CATCH err AS Progress.Lang.SysError: /* Handle error here */ MESSAGE err:GetMessage(1). END CATCH. END. DEV-12 What’s New in the Object-Oriented ABL

Error Handling Example: Application Error CATCH put on existing DO block for running a procedure… DO ON ERROR, UNDO LEAVE: RUN doIt.p. /* RETURNS AppError */ MESSAGE "Never reach here". CATCH err AS Progress.Lang.AppError: /* Handle error here */ MESSAGE err:ReturnValue. END CATCH. END. DEV-12 What’s New in the Object-Oriented ABL

Wouldn’t It Be Great If… CHARACTER data could be passed for a LONGCHAR NEW could be called as an expression Reserved keywords could be used for class member names THIS-OBJECT could be used to qualify a class member DEV-12 What’s New in the Object-Oriented ABL

Data Widening More flexible parameters passing 10.1B New for 10.1C Strong-typing rules for compatibility More flexible parameters passing 10.1B New for 10.1C Narrower to Wider INTEGER > INT64 > DECIMAL DATE > DATETIME > DATETIME-TZ Narrower(32K) to Wider (1GB) CHARACTER > LONGCHAR DEV-12 What’s New in the Object-Oriented ABL

NEW function NEW statement ( 10.1A ) NEW function ( 10.1C ) Similar to an assignment Assigns an object reference to a variable NEW function ( 10.1C ) Object created as part of an expression Returns a reference to new object No need to assign it to an intermediate variable DEV-12 What’s New in the Object-Oriented ABL

Caution Using NEW function Object cleanup Object not assigned to anything – memory leak! Object assigned to something Parameter receiving object responsible for cleanup MESSAGE “Using NEW function” (NEW myObject()):myMethod( ). RUN myProc.p ( INPUT NEW myObject() ). DEV-12 What’s New in the Object-Oriented ABL

Caution Using NEW function Object cleanup Object not assigned to anything – memory leak! Object assigned to something Parameter receiving object responsible for cleanup Garbage Collection planned for 10.2A MESSAGE “Using NEW function” (NEW myObject()):myMethod( ). RUN myProc.p ( INPUT NEW myObject() ). DEV-12 What’s New in the Object-Oriented ABL 44

Reserved Keywords in Classes ABL Reserved Keywords can be used for: Class names Best to prefix with packages Method names CLASS Form: CONSTRUCTOR PUBLIC Form( ): … METHOD PUBLIC INT Create( ): DEFINE VAR myClass AS CLASS Form. myClass = New Form( ). myClass:Create( ). DEV-12 What’s New in the Object-Oriented ABL

THIS-OBJECT as a Local Qualifier Qualifier used inside a class when accessing local method, variable, and property names Identifies member as class instance Enables content assist in Architect Required when a local method name is a reserved keyword CLASS Form: CONSTRUCTOR PUBLIC Form( ): THIS-OBJECT:Create( ). END. METHOD PUBLIC INT Create( ): … DEV-12 What’s New in the Object-Oriented ABL

Agenda Overview of Object-oriented ABL 10.1C Features Futures Static behavior and data Dynamic programming Error handling Data widening, NEW function, reserved keywords, THIS-OBJECT Futures DEV-12 What’s New in the Object-Oriented ABL

Under Development 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. D I S C L A I M E R DEV-12 What’s New in the Object-Oriented ABL

Expected 10.2A Functionality Properties in Interfaces Defines data portion of contract Advanced GUI New UI Model Access to .NET UI Classes Garbage collection Automatic cleanup Array Enhancements Arrays of Objects Public arrays variables and properties Return value support for methods and functions Vector assignment DEV-12 What’s New in the Object-Oriented ABL

A Glimpse Further into the Roadmap Strongly-typed events Define, Publish and Subscribe in Classes Remote objects Pass objects across an AppServer Abstract methods Force implementation in subclasses Inheritance for Interfaces Allow one Interface to inherit from another DEV-12 What’s New in the Object-Oriented ABL

Relevant Exchange Sessions DEV-8: Structured Error Handling in the ABL DEV-22: Catch Me if You Can – Practical Structured Error Handling DEV-38: OpenEdge ABL Info Exchange DEV-41: The Power of Polymorphism DEV-12 What’s New in the Object-Oriented ABL

? Questions DEV-12 What’s New in the Object-Oriented ABL

Thank You DEV-12 What’s New in the Object-Oriented ABL

DEV-12 What’s New in the Object-Oriented ABL