AN OBJECT LESSON IN CLASSES “or how OO ABL solves everything.”

Slides:



Advertisements
Similar presentations
Object Oriented Programming with Java
Advertisements

Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
OpenEdge® Object-oriented ABL
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ITEC200 – Week03 Inheritance and Class Hierarchies.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
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.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
Object-oriented Programming Concepts
Terms and Rules Professor Evan Korth New York University (All rights reserved)
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
Inheritance using Java
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
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.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Programming in Java CSCI-2220 Object Oriented Programming.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Review Class Inheritance, Abstract, Interfaces, Polymorphism, GUI (MVC)
DEV-6: Advanced Object-Oriented Programming in the ABL Evan Bleicher Senior Development Manager Shelley Chase
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
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
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Peter Judge A8: What’s New in Object-Oriented ABL Principal Software Engineer OpenEdge 10.1C and beyond.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Advanced Programming in Java
Advanced Programming in Java
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Java Programming Language
Interfaces.
Advanced Java Programming
Advanced Programming in Java
Java Inheritance.
Advanced Programming in Java
Object-Oriented Programming in PHP
Fundaments of Game Design
Chapter 9 Carrano Chapter 10 Small Java
Chapter 14 Abstract Classes and Interfaces
Presentation transcript:

AN OBJECT LESSON IN CLASSES “or how OO ABL solves everything.”

BRIEF INTRODUCTION Julian Lyndon-Smith, IT Director dot.r limited Progress developer since v3, 1987 Living proof of “old dog, new tricks” Often hanging around on PEG and PSDN Always up for a good argument ;)

AGENDA Who’s afraid of the big bad wOOlf ? Basics Getting rid of the garbage Inheritance, interfaces and all that Advanced OO Gotchas Real world code... Warts and all …

WHO’S AFRAID OF THE BIG BAD W OO LF ? Survey : Progress version <10.2B 10.2B

WHO’S AFRAID OF THE BIG BAD W OO LF ? Survey : Who’s using OO Not yet Dabbling Sometimes Mostly Wizard

BASICS : OO ADVANTAGES Type-safe Cannot tipe a bad metgod name Encapsulation Group together methods and data Code reuse

BASICS : OO ADVANTAGES Code completion Makes you really cool Talking about the fancy OO terms like “injection”, “factory”, “instantiation”, “inheritance” allows you to hang out with the cool kids

BASICS A class is an 4gl file with a.cls extension Compiles to.r Two parts: package and class name Package is the directory where source lives foo.bar.MyClass is foo/bar/MyClass.cls Using statement

BASICS An instance is a running class Similar to persistent procedures Run foo.p persistent set x x = new foo().

BASICS : CREATE AN INSTANCE /** foo/bar/MyClass.cls */ class foo.bar.MyClass: end class. def var oFoo as foo.bar.MyClass no-undo. oFoo = new foo.bar.MyClass().

BASICS: PROPERTIES A property can be described as a procedure-wide “variable” Extra toys to play with : get / set etc Public and private

BASICS : PROPERTIES /** foo/bar/MyClass.cls */ class foo.bar.MyClass: def public property guid as char no-undo get. set. end class. def var oFoo as foo.bar.MyClass no-undo. oFoo = new foo.bar.MyClass(). Message oFoo:guid view-as alert-box.

BASICS: PROPERTIES Def [public | protected | private] [public | protected | private] get. [public | protected | private] set.

BASICS: METHODS A method can be described as a function Without having to forward declare it Returns a value or void Can optionally have parameters

BASICS : METHODS /** foo/bar/MyClass.cls */ class foo.bar.MyClass: method public void DoStuff(): /** do some stuff */ end method. end class. def var oFoo as foo.bar.MyClass no-undo. oFoo = new foo.bar.MyClass(). oFoo:DoStuff().

BASICS : METHODS /** foo/bar/MyClass.cls */ class foo.bar.MyClass: method public void DoStuff(p_name as char): /** do some stuff */ Message p_name view-as alert-box. end method. end class. def var oFoo as foo.bar.MyClass no-undo. oFoo = new foo.bar.MyClass(). oFoo:DoStuff(“my_little_pony”).

BASICS: METHODS Method [public | protected | private]

GETTING RID OF THE GARBAGE Persistent procedures can create memory leaks Run foo.p persistent set x. Must remember to delete x or memory leaks Classes have an automatic Garbage collector Automatically deletes unreferenced class instances You have no control over this

GETTING RID OF THE GARBAGE run DoMyStuff in this-procedure. /** do some more things like UI */ procedure DoMyStuyff: def var oFoo as foo.bar.MyClass no-undo. oFoo = new foo.bar.MyClass(). oFoo:DoStuff(). end procedure.

NOT GETTING RID OF THE GARBAGE def var oFoo as foo.bar.MyClass no-undo. run DoMyStuff in this-procedure. /** do some more things like UI */ procedure DoMyStuyff: oFoo = new foo.bar.MyClass(). oFoo:DoStuff(). end procedure.

INHERITANCE, INTERFACES AND ALL THAT Inheritance Interfaces Polymorphism Abstracts

INHERITANCE Abstract out common functionality (and data) from similar classes A sub-class inherits from a super-class A sub-class can extend or change behavior of super-class Overriding methods Adding new methods / properties

INTERFACES Specifies a set of method prototypes and properties Similar to inheritance No default implementation methods or properties Allows you to build different classes that conform to an API Each class that uses an Interface must implement all methods and properties defined in the interface Convention is that interface files start with an I

POLYMORPHISM As shown previously, multiple classes can inherit from same super-class Sub-classes can override methods or behavior in the super-class Multiple implementations (different parameters) Different behavior : Same method, multiple signatures Super:Method()

ABSTRACTS Abstracts are classes than cannot be instantiated by themselves Need to inherit an abstract class All appropriate properties and methods are available to sub-class

ADVANCED OO Events Chaining Parameter passing Statics

ADVANCED OO : EVENTS Classes can raise “named” events Define Listen Raise

ADVANCED OO : EVENTS def public event StateChanged signature void (p_msg as char). StateChanged:publish(“foo”).

ADVANCED OO : EVENTS Def var oMessage as foo.Message no-undo. oMessage = new foo.Message(). oMessage:StateChanged:Subscribe(this-object:StateChanged). /** do stuff */ Method public void StateChanged(p_state as char): message p_state view-as alert-box info. End method.

ADVANCED OO : CHAINING Also called Fluent-style coding Fluent-coding style Methods return an instance of a class which is then used to call another method Confused ?

ADVANCED OO : CHAINING Association(BelongsTo("State"):Keys("StateID","State"):CascadeNullify()). Assocation(p_prop as dotr.property) dotr.property – method BelongsTo [dotr.property] (p_name) dotr.property – method Keys [dotr.property] (p_key1,p_key2) dotr.property – method CascadeNullify() Association( BelongsTo("State") :Keys("StateID","State") :CascadeNullify() ).

ADVANCED OO : CHAINING (new foo.bar()):DoStuff(). ** No need for variable Does stuff Gets GC’d automatically ** new foo.bar():DoStuff(). Hopefully in 11.3

ADVANCED OO : PARAMETER PASSING Parameters : pita Change over time Need to write new ip’s to handle new parameters May need to revisit old code and change

ADVANCED OO : PARAMETER PASSING Use an instance of a class as a Parameters Change properties of class All inputs now have additional properties without changing a line of code Input == input-output

ADVANCED OO : STATICS A static method is loaded into memory. Once. Can then use that method without having to define a variable Foo.bar() Foo is the class, bar is a static method

ADVANCED OO : STATICS Tempting to use Cannot be unloaded at all from session Do not use record buffers in any method of a class that has a static member Buffers are then “locked” into memory Impossible to update db whilst app is running

GOTCHAS Event Subscription Potentially no garbage collection Sockets AppServer boundaries No serialization

GOTCHAS Statics OO-guys can sound more intelligent than you Doing stuff in the constructor

SHOW ME THE CODE Demos and walkthroughs of the various technqiues perhaps even “on demand coding”

QUESTIONS, DEBATE