Article Preview
Buy Now
| Print: | |
| PDF: |
Object-Oriented Thinking
Implementing the Monostate Pattern
Static Variables In Action
Issue: 4.1 (September/October 2005)
Author: Charles Yeomans
Article Description: No description available.
Article Length (in bytes): 4,853
Starting Page Number: 33
RBD Number: 4115
Resource File(s): None
Related Web Link(s):
http://www.quantum-meruit.com/rb/
Known Limitations: None
Excerpt of article text...
REALbasic 2005 adds the concept of a static variable to the language. To get a grasp of this new addition, consider the concept of a local variable. A local variable is a chunk of storage allocated in a method. This variable is created anew every time the method executes, thus each executing copy of the method has its own local storage.
A static variable is also a chunk of storage allocated in a method. Unlike a local variable, a static variable is created and initialized once, remains in existence until the application quits, and is shared by all executing copies of the method. Like a local variable, the visibility of a static variable is limited to the method in which it is declared.
It is important to understand that static variables belong to the method, not the object or module to which the method is attached. Thus the creation and destruction of objects do not affect the value of static variables.
Static Properties
Static variables should not be confused with class properties, though they will be. Although REALbasic does not offer class properties, it is possible to implement the functionality of class properties using static variables, if not the syntax.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|







