Special

Special Print Offer

Get the RBD Archive 7 printed book for FREE when you buy an Ultimate Combo printed back issue package! This perfect-bound book is over 300 pages and contains the full year 7 of RBD. Normally this book sells for $50, but with this special offer you not only save 25% off the normal package price, you get the book included for free!

RBD Magazines

Supplies are limited, so take advantage of this offer before it goes away.

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.


 


|

 


Weblog Commenting and Trackback by HaloScan.com