[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Class Methods
Class methods are declared using the CLASS METHOD command.
A class method is a method which operates on an entire class (or a subset
of a class), rather than on a single instance of that class. Any operation
which deals with more than one instance of a class is a good candidate for
a class method.
In a class method, the self variable refers to the class object for
that class. This means that class methods can access class variables
directly. For example, in the previous section, the expression:
::class:currSelected
was used to access the class variable currSelected. In a class method,
we would instead use ::currSelected to access the variable.
If a regular method is accessing class variables and methods repeatedly,
it is worth exploring whether that aspect of its operation can be
extracted and made into a class method. It is more efficient to access
class variables from within a class method. Also, it often makes better
sense from a conceptual design perspective to encapsulate, within a class
method, code which repeatedly uses class messages.
See Also:
CLASS METHOD
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson