OOBJECT AND THE DEBUGGER - STATIC Methods:
------------------------------------------
Up to version 1.b it was practically impossible to use the debugger with
oObject. Libraries like oObject, oClip, oOclip etc. that use (and abuse)
METHOD Name "mangling" are very difficult to debug because the debugger
expects a METHOD UDF to be the same name as the METHOD message otherwise it
gives an "undefined function" error and terminates:self <g> ; for more info
on the subject read the oClip.doc
It is possible to write classes that use the same name for METHOD messages
and their METHOD UDFs, using the existing tools and syntax in the above
mentioned class libraries, but in real life this is not possible because
that would mean you would get "duplicate symbol/function" errors at link
time (how many different ::display() methods would you write), plus it
would be the end of polymorphism as we know it.
In version 2.00, oObject implements an additional way of declaring METHOD
names and METHOD UDFs that have the same name but are also STATIC in their
source .prg and 100% visible to the debugger. The solution was in the lib
from the very beginning but it came to me one night at about 3:00 am and I
didn't even have to change the source files. I just added 4 additional
commands in the header and it was working !!!
Note (1): You can use any type of syntax within your source. This means
that you can mix PUBLIC, STATIC, GETSET, INLINE, BLOCK, LINKED etc. METHODS
in your source as long as you keep the syntactical conventions for each
data type.
Note (2): Keep in mind that STATIC Methods are infact INLINE IVars. Using
this feature will eventually raise the number of IVars contained in the
class. oObject supports up to 250 IVars in a single class.
Advantages of STATIC Methods:
----------------------------------
o Cleaner syntax:
The parameters passed to each method are declared at class initiation so they are easier to review and maintain.
o Less runtime overhead:
All your METHOD UDFs can be declared as static using this technique, so you only have ONE public function per class.
o Faster execution speed:
Your class executes STATIC functions through code blocks.
o 100% Debugger support:
Since methods and messages share the same name, the debugger sees all of
them transparently and processes them like normal functions.
o Complete OBJECTS 1.00 & 2.00 syntax compatibility:
Users of objects.lib (of FiveWin) can compile their code using
oObject.ch with minimum or no modifications.
o Complete oOBJECT compatibility:
You can use your existing oObject code and jump to the alternate syntax
whenever you wish... No modifications have been done to the source code.
Actually, you can combine any of the different oObject data types in a
single .prg without any problems whatsoever.
o Better Polymorphism support.
o Inheritance is not affected by the use of STATIC functions. Just remember
to ALIAS your parent classes and to use ALIASed parent methods to invoke
parent.
o Reusable Method Functions - if public.
Disadvantages:
--------------
o You MUST use the alternate syntax to use this feature.
o There is an ongoing dispute regarding the speed of codeblocks vs public functions.
o When you change the parameters passed to a METHOD UDF you must edit
your source in two places.
o You may only write one class per .prg file otherwise identical METHOD
UDFs used in two classes will produce "duplicate function name"
compiler warnings.
o Don't self:overdoit <g>. If you can use an INLINE statement instead you
avoid writting an extra function call for your class. STATIC functions
are still functions and they take up space.
Syntax:
-------
CLASS Something
...
// Method Messages
// 2 ways to call them
...
METHOD <Method>( uParms,... ) // Normal Message
...
CLASS METHOD <Method>( uParms,... ) // Class Message (Not inherited)
...
ENDCLASS
...
// Method UDFs - Same <Method> name as above...
// 6 ways to call them.
METHOD <Method>( uParms,... )
...
METHOD FUNCTION <Method>( uParms,... ) CLASS <ClassName>
...
METHOD ClassName::<Method>( uParms,... )
...
METHOD ::<Method>( uParms,... )
...
METHOD <Method>( uParms,... ) CLASS <ClassName>
...
STATIC METHOD <Method>( uParms,... )
...