DEV7 Whats New in ObjectOriented ABL Open Edge
DEV-7: What’s New in Object-Oriented ABL Open. Edge 10. 1 C and beyond Shelley Chase Open. Edge Architect
Agenda § Overview of Object-oriented ABL § 10. 1 C Features • • Static behavior and data Dynamic programming Error handling Data widening, NEW function, keywords, THIS-OBJECT reserved § Futures 2 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
What is Object-oriented ABL… Open. Edge 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 3 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Benefits of Procedural and OO Programming Open. Edge is committed to both programming models § Procedures and Classes • Modular programming • Supports reuse of common behavior (super) • Maps well to Open. Edge 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) 4 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Agenda § Overview of Object-oriented ABL § 10. 1 C Features • • Static behavior and data Dynamic programming Error handling Data widening, NEW function, keywords, THIS-OBJECT reserved § Futures 5 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 6 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 My. Class obj. Ref = 1004 1012 1008 Data Open. Edge Runtime 7 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Instance Data CLASS My. Class: DEF VAR my. Class. Ref AS CLASS My. Class. … my. Class. Ref = NEW CLASS My. Class( “Joe” ). DEFINE PUBLIC PROPERTY Count AS INT DELETE OBJECT my. Class. Ref. GET. SET. my. Class. Ref = NEW CLASS My. Class( “Tim” ). DEFINE PUBLIC PROPERTY Name AS CHARACTER DELETE OBJECT my. Class. Ref. GET. SET. my. Class. Ref = NEW CLASS My. Class( “Ann” ). DELETE OBJECT my. Class. Ref. CONSTRUCTOR My. Class ( in. Name AS CHARACTER Name = in. Name. Count = Count + 1. END CONSTRUCTOR. END CLASS. 8 DEV-7 What’s New in the Object-Oriented ABL Count = 1 Name = Joe Count = 1 Name = Tim Count = 1 ): Name = Ann © 2008 Progress Software Corporation
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 My. Class “My. Class: ” Static Data Open. Edge Runtime 9 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Static Data Count = 2 3 1 CLASS My. Class: = My. Class: Count + 1. My. Class: Count Name = Tim Ann Joe … My. Class: Name = “Joe”. DEFINE PUBLIC STATIC PROPERTY Count AS INT GET. My. Class: Count = My. Class: Count + 1. SET. My. Class: Name = “Tim”. DEFINE PUBLIC STATIC PROPERTY Name AS CHARACTER GET. My. Class: Count = My. Class: Count + 1. SET. My. Class: Name = “Ann”. CONSTRUCTOR My. Class ( in. Name AS CHARACTER ): Name = in. Name. Count = Count + 1. END CONSTRUCTOR END CLASS. 10 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 11 © 2008 Progress Software Corporation
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 DEFINE PUBLIC STATIC PROPERTY Count AS INT GET. SET. § Available anywhere in the session • Single instance life-cycle controlled by the AVM • Access using class type name MESSAGE My. Class: Count. 12 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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!) CONSTRUCTOR STATIC My. Class ( ): Count = 0. /* Initialize static counter */ END. § Run automatically before any class member access is allowed 13 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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!) METHOD STATIC PUBLIC INT Display. Message( c AS CHAR ): MESSAGE c VIEW-AS ALERT-BOX. END. § Available anywhere in the session • Access using class type name My. Class: Display. Message( “Statics are cool” ). 14 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Accessing a Static Class Member /* My. Class class not instantiated */ MESSAGE My. Class: Count VIEW-AS ALERT-BOX. My. Class § Access static data member Count • 15 DEV-7 What’s New in the Object-Oriented ABL Runtime checks if static class members are loaded; it’s not so © 2008 Progress Software Corporation
Accessing a Static Class Member /* My. Class class not instantiated */ MESSAGE My. Class: Count VIEW-AS ALERT-BOX. My. Class § STATIC tt. Users Count 16 DEV-7 What’s New in the Object-Oriented ABL Access static data member Count • Runtime checks if static class members are loaded; it’s not so – Creates static global data segment § tt. Users and Count © 2008 Progress Software Corporation
Accessing a Static Class Member /* My. Class class not instantiated */ MESSAGE My. Class: Count VIEW-AS ALERT-BOX. My. Class STATIC tt. Users = … Count = 0 17 § Access static data member Count Joe • Runtime checks if static class Tim members are loaded; it’s not so Ann DEV-7 What’s New in the Object-Oriented ABL – Creates static global data segment § tt. Users and Count – Runs static constructor § Initialize Count and tt. Users © 2008 Progress Software Corporation
Accessing a Static Class Member /* My. Class class not instantiated */ MESSAGE My. Class: Count VIEW-AS ALERT-BOX. My. Class § STATIC tt. Users = … Count = 0 18 DEV-7 What’s New in the Object-Oriented ABL Access static data member Count • Runtime checks if static class members are loaded; it’s not so – Creates static global data segment § tt. Users and Count – Runs static constructor § Initialize Count and tt. Users – Gets value of Count © 2008 Progress Software Corporation
New’ing a Class with Static Members DEFINE VAR obj. Ref AS My. Class. obj. Ref = NEW CLASS My. Class( “Joe” ). My. Class § STATIC tt. Users = … Count = 0 19 DEV-7 What’s New in the Object-Oriented ABL NEW an instance of My. Class • Runtime checks if static class members are loaded; it is. © 2008 Progress Software Corporation
New’ing a Class with Static Members DEFINE VAR obj. Ref AS My. Class. obj. Ref = NEW CLASS My. Class( “Joe” ). My. Class § STATIC tt. Users = … Count = 0 NEW an instance of My. Class • Runtime checks if static class members are loaded; it is. • Creates local data segment – name Instance name 20 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
New’ing a Class with Static Members DEFINE VAR obj. Ref AS My. Class. obj. Ref = NEW CLASS My. Class( “Joe” ). My. Class § STATIC tt. Users = … Count = 1 NEW an instance of My. Class • 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 • Instance name = Joe 21 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
New’ing a Class with Static Members DEFINE VAR obj. Ref AS My. Class. obj. Ref = NEW CLASS My. Class( “Joe” ). My. Class § STATIC tt. Users = … Count = 1 NEW an instance of My. Class • 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 • Instance name = Joe 22 § DEV-7 What’s New in the Object-Oriented ABL Assigns new instance to object reference © 2008 Progress Software Corporation
New’ing a Class with Static Members DEFINE VAR obj. Ref 2 AS My. Class. obj. Ref 2 = NEW CLASS My. Class( “Tim” ). My. Class § STATIC tt. Users = … Count = 2 23 • 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 • § Instance name = Joe NEW an instance of My. Class Assigns new instance to object reference Instance name = Tim DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
New’ing a Class with Static Members DEFINE VAR obj. Ref 3 AS My. Class. obj. Ref 3 = NEW CLASS My. Class( “Ann” ). My. Class § STATIC tt. Users = … Count = 3 24 • 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 • § Instance name = Joe NEW an instance of My. Class Assigns new instance to object reference Instance name = Tim DEV-7 What’s New in the Object-Oriented ABL Instance name = Ann © 2008 Progress Software Corporation
Singleton Design Pattern § § § Single instance of the class Available from anywhere within the session Loaded on demand Singleton Class § Instance Data members • § § § 25 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-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Demo – Singleton Class 26 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Developing with STATIC Members Static lifecycle controlled by Open. Edge 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 27 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Developing with STATIC Members Static lifecycle controlled by Open. Edge Runtime § Static class members loaded for the life of the session § • When a. cls file is changed and re-compiled, t the static portion is NOT refreshed c e t i h rc A e Us ch n u Caution during development a L s n o i t ra u g i f • One active session Con shared by application and development environment • Recompile does not reload any static changes – Runtime error for mismatches can occur • Session must be restarted 28 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 29 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 30 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Dynamic Object Creation § DYNAMIC-NEW Business. Entity • Used to create a new instance – Fully qualified character type name § USING is not used – Common parameter list BEEmployee BECustomer • Returns a strongly-typed object – Type checked at runtime METHOD Business. Entity Create. BE( be. Type AS CHAR): DEFINE VARIABLE my. Obj AS Business. Entity. my. Obj = DYNAMIC-NEW STRING(“BE” be. Type)(parm 1, …). “BE” + be. Type RETURN my. Obj. END METHOD. 31 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Dynamic Object Casting § DYNAMIC-CAST Business. Entity • Used to cast an object reference – Fully qualified character type name § USING is not used • Returns a strongly-typed object BEEmployee BECustomer – Type checked at runtime METHOD Business. Entity Create. BE( be. Type AS CHAR): DEFINE VARIABLE my. Obj AS Business. Entity. my. Obj = DYNAMIC-NEW STRING(“BE” be. Type)(parm 1, …). “BE” + be. Type DYNAMIC-CAST( my. Obj, STRING(“BE” be. Type). “BE” + be. Type RETURN my. Obj. END METHOD. 32 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Class. Factory Design Pattern § § Class returns different types of classes Available from anywhere within the session Class. Factory Class § Creates different classes • Common super class for all classes • Common set of constructor parameters § Type name passed in at runtime § 33 Alternative is a large CASE statement DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Demo – Class Factory 34 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 35 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 36 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Error Object Hierarchy Progress. Lang. Object Progress. Lang. Error <<interface>> Progress. Lang. Pro. Error Application Errors 37 System Errors Progress. Lang. App. Error Progress. Lang. Sys. Error User-Defined Error Objects Progress. Lang. Soap. Fault. Error DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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. Sys. Error: /* Handle error here */ MESSAGE err: Get. Message(1). END CATCH. END. 38 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Error Handling Example: Application Error § CATCH put on existing DO block for running a procedure… DO ON ERROR, UNDO LEAVE: RUN do. It. p. /* RETURNS App. Error */ MESSAGE "Never reach here". CATCH err AS Progress. Lang. App. Error: /* Handle error here */ MESSAGE err: Return. Value. END CATCH. END. 39 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 40 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Data Widening Strong-typing rules for compatibility § More flexible parameters passing • 10. 1 B Narrower INTEGER > DATE > to INT 64 > DATETIME > Wider DECIMAL DATETIME-TZ • New for 10. 1 C Narrower(32 K) CHARACTER 41 DEV-7 What’s New in the Object-Oriented ABL to > Wider (1 GB) LONGCHAR © 2008 Progress Software Corporation
NEW function § NEW statement ( 10. 1 A ) • Similar to an assignment • Assigns an object reference to a variable § NEW function ( 10. 1 C ) • Object created as part of an expression • Returns a reference to new object • No need to assign it to an intermediate variable 42 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Caution Using NEW function § Object cleanup • Object not assigned to anything – memory leak! MESSAGE “Using NEW function” (NEW my. Object()): my. Method( ). • Object assigned to something – Parameter receiving object responsible for cleanup RUN my. Proc. p ( INPUT NEW my. Object() ). 43 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Caution Using NEW function § Object cleanup • Object not assigned to anything – memory leak! ge a b r a MESSAGE “Using GNEW function” n o i t c (NEW my. Object()): my. Method( ). Colle d for e n n a l • Object assignedpto something 10. 2 A – Parameter receiving object responsible for cleanup RUN my. Proc. p ( INPUT NEW my. Object() ). 44 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Reserved Keywords in Classes § ABL Reserved Keywords can be used for: • Class names – Best to prefix with packages • Method names CLASS DEFINEForm: VAR my. Class AS CLASS Form. CONSTRUCTOR Form( ): my. Class = New PUBLIC Form( ). … my. Class: Create( ). METHOD PUBLIC INT Create( ): … 45 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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( ): … 46 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Agenda § Overview of Object-oriented ABL § 10. 1 C Features • • Static behavior and data Dynamic programming Error handling Data widening, NEW function, keywords, THIS-OBJECT reserved § Futures 47 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
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 48 I S C DEV-7 What’s New in the Object-Oriented ABL L A I M E R © 2008 Progress Software Corporation
Expected 10. 2 A 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 • • 49 Arrays of Objects Public arrays variables and properties Return value support for methods and functions Vector assignment DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
A Glimpse Further into the Roadmap § Strongly-typed events • Define, Publish and Subscribe in Classes § Remote objects • Remote access to objects on an App. Server § Abstract methods • Force implementation in subclasses § Inheritance for Interfaces • Allow one Interface to inherit from another 50 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Relevant Sessions PSDN Live 2008 Sessions § DEV-4: Structured Error Handling in the ABL § DEV-19: Open. Edge ABL Info Exchange 2008 Recorded Sessions § DEV-22: Catch Me if You Can – Practical Structured Error Handling § DEV-41: The Power of Polymorphism 51 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
? Questions 52 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
Thank You 53 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
54 DEV-7 What’s New in the Object-Oriented ABL © 2008 Progress Software Corporation
- Slides: 54