Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 17 in printed book and digital formats -- plus a one-year subscription (beginning with 18.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 3.2


Implementing the Singleton Pattern

Issue: 3.2 (November/December 2004)
Author: Charles Yeomans
Author Bio: Charles Yeomans is a software developer in Lexington, Kentucky.
Article Description: No description available.
Article Length (in bytes): 5,837
Starting Page Number: 33
Article Number: 3215
Related Link(s): None

Excerpt of article text...

It is sometimes the case that not only do you want to implement a single instance of a class, but that you also need to prevent more than one instance from being created. This is the Singleton pattern.

The usual way to implement a singleton in REALbasic is with a module. Modules are created at startup, and you cannot create multiple instances of them. A minor disadvantage is that modules don't support constructors and destructors, but that's easy enough to work around with methods to be called in App.Open and App.Close. However, if you need to create a singleton object that is a subclass of another class, then you can't use a module.

...End of Excerpt. Please purchase the magazine to read the full article.