Are this information applicable also to harbour?
ftp://ftp.alaska-software.com/documents/oop-6-rules.pdf

„Class“ is an abstract term. The Xbase++ runtime knows class object and instance
objects. Class objects are created at the first time the class
function is executed, subsequent class function execution returns the same class
object.
To „free“ a class object the function ClassDestroy() can be used. The Xbase++
runtime has a process-global hashtable used to associate class objects with
class names.
ClassDestroy() simply removes the name<->class object
association. However the class object is not freed until the last
instance object of this class is destroyed.
:New() is the default constructor to create instance objects. Instance objects
are always created by class objects.
Therefore class objects are sometimes called „Object
Factories“. You can have an unlimited amount instance objects
of the same class. In the following the term object is used to
describe instance objects.

Note: Class objects which reference code or data of a DLL lead to sideeffects
such as that the DLL is not unloadable until all objects of the class are
destroyed and the class object itself has been destroyed. Until this
precondition is met the DLL can not be unloaded.

All class are dynamyc
There is no difference between a class object created from a class function A()
generated by the
compiler and a class object created with
CreateClass() by a Function A().
Runtime-classes can replace compile-time classes
and vice versa. Any class can be replaced by
another class with the same name. That‘s why
classes are dynamic.
The FREEZE attribute at CLASS declaration
prohibits the implicit replacement of this class.
FREEZE can be used to protect class
implementations from being replaced implicitly.
The FINAL attribute prohibits subclassing of this
class. The behaviour of FINAL classes can therefore be no longer changed -It is
FINAL

Consider the code on the right side:
Executing the method :Bark() on
objects of Class A executes method
:Print() at Class A. Executing the
method :Bark() on objects of Class B
executes the method :Print()
implemented at Class B.
This behaviour is called virtual override
because each method implementation
in a subclass does override a possible
implementation of its superclasses
- Overriding of METHOD is always a replacement
method replacement totally overwrites the
method of its base classes during execution. That is the code in the base class
is never executed when instances of subclasses are manipulated. The
Class B and the method :Print() is an example of
method replacement.
Refinement can be achieved as outlined in Class C. To do that, we must be able
to execute the
superclass implementation. The SUPER statement
is used to refer to the direct superclass
implementation. The SUPER statement executes the superclass implementation of
the current
method and passes all parameters passed to this
method. SUPER:Print() can be used as an
alternative to control method name and
parameters passed.
Note: You can write SELF:A:

Consider the code on the right side:
Executing the method :PrintA() on
objects of Class B prints „Value from A“,
while executing the method :PrintB()
shows „Value from B“.
This behaviour is called hiding in OO
terms. It simple means that redefining
a variable in a subclass hides the
variable of its superclass. It therefore
introduces the variable.

CLASS A
EXPORTED:
VAR Lastname
INLINE METHOD Init()
::LastName:= „ValuefromA“
RETURN
INLINE METHOD PrintA()
? ::LastName
RETURN
ENDCLASS
CLASS B FROM A
EXPORTED:
VAR Lastname
INLINE METHOD Init()
::A:Init()
::LastName:= „ValuefromB“
RETURN
INLINE METHOD PrintB()
? ::LastName
RETURN
ENDCLASS


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to