Richard Taylor - Easing into OOP
by Mike Hanson
Published 1997-09-01
Printer-friendly version
Richard Taylor gave an extremely well-organized and educational
presentation entitled "Easing into OOPs". For those audience
members who were new to OOP, they could not have attended a more
informative session to get them ramped-up.
With Clarion 4 moving so much into the OOP world, many
developers will be dragged kicked and screaming into this new
environment. Once they realize the benefits and recognize that
it's actually not that hard, they should be a little more
comfortable with it. Richard's session was the perfect head
start for this expedition. This was by far the most concise and
understandable presentation of this material that I've ever
seen.
Using non-OOP methods (i.e.: CW 2.0 applications), each
procedure contains both the code and data to perform its job. With
OOP, all procedures share the same basic code, and only the data
and code variations are unique to each procedure. This results in a
significant savings over non-OOP programming.
The terms that Richard covered were:
- Class - This structure is used to define
an "object" in CW.
- Property - This is object data in a
Class. As was mentioned above, each object gets its own copy of the
data.
- Method - This is a procedure or function
associated with the Class. All objects derived from this class will
share the same code.
- Encapsulation - This merely implies that
the complexity of the classes is hidden within the class
definitions. Additionally, properties and methods may be "PRIVATE"
to the Class (not accessible outside the Class) or "PROTECTED"
(accessible only within the Class itself, and in any other Classes
derived from the original Class).
- Instantiation - This occurs when an
actual instance of object is created at run-time. At that time, the
object's data is allocated and initialized. If a Class is
defined without the TYPE attribute, it will automatically be
treated as both a Type and an Instance. New objects can be
instantiated by referring to this new Class Type.
- Reference - This is a variable that
refers to an actual instance of a particular type of variable
(e.g.: reference to a QUEUE). The actual data space must be created
with the NEW command, and destroyed with the DISPOSE command.
- Constructors and
Destructors - If procedures called
"Construct" and "Destruct" are declared as class members, the
Construct procedure will be called when the object is created, and
the Destruct procedure will be called when it is disposed. These
procedures, which cannot take parameters or return a value, could
be used for creating and destroying Reference variables, and other
housekeeping chores.
- Inheritance - This occurs when a new
class is defined by deriving an existing class. It will
automatically acquire all attributes and methods of its parent
class. When both the parent and child classes have their own
constructors and destructors, the constructors are called in order
from the parent down to the child, while the destructors are called
in reverse order.
- Composition - This is a technique that
can be used to simulate multiple inheritance (where a single new
class is created by deriving from two or more existing classes).
Essentially, a Reference variable is defined within the new Class
for each additional parent Class beyond the first. It's not
quite as good as multiple-inheritance, but it does avoid the
problem of "disambiguation".
- Polymorphism - A single method name can
have multiple definitions with different parameter lists. This
allows the object's methods to be called depending on the type
of task to be performed. Polymorphism also related to "Virtual
Methods".
- Overridden Method - When a Method is
declared in a derived child Class that also exists in its parent
class, the child's Method will be called instead of the
parent's. If the child's Method is adding only partial
functionality to the parent Method, then it must manually call the
parent's method itself.
- Virtual Method - This is a special type
of overridden method. With a normal override, methods in the parent
class will still call the parent's method, while methods in
the child class (and elsewhere) will call the child's method.
A virtual method is called by everyone (including the parent's
methods). Richard's description probably said it best:
"Inheritance allows Derived Class methods to "call down" to Parent
Class methods. Virtual Methods are the opposite: they allow Parent
Class methods to "call up" to execute the Derived Class
methods."
- Late Binding - This is a technique that
is required when using Virtual Methods. The parent class does not
know which of its children's virtual methods will be called
until it is actually needed. It simply knows that there might be a
different method that must be called at run-time. This is
substantially different from regular compilation, where all call
references are resolved at link time.
- Local Derived Methods - This is a new
scoping feature added to CW Beta 2. Normally local data and
routines can be accessed only within the procedure in which they
are declared. Now they can also be accessed from the methods
defined in derived classes that are local to the original
procedure.
This was a huge amount of material cover in a single hour, and
Richard did an admirable job. The best tribute that we can pay to
him now is to read his equally impressive documentation for C4. For
those of you who are still intimidated by OOP, give it a try -
you may be surprised and fall head over heels in love with
it.
Printer-friendly version

Copyright © 1999-2008 by CoveComm Inc. All Rights Reserved.
Reproduction in any form without the express written consent of CoveComm Inc.,
except as described in the subscription
agreement, is prohibited.
Clarion Magazine ISSN 1718-9942