On Feb 21, 2006, at 9:28 PM, Guyren Howe wrote:

On Feb 21, 2006, at 5:57 PM, Joseph J. Strout wrote:

Now that REALbasic 2006 has shared methods and shared properties, is it possible to have a true Singleton object?

Sure -- but then, it was quite possible before too, except that the enforcement was at runtime rather than at compile time.

The current shared methods and properties make the class behave like a module, not like an object (which is what a singleton should be). You can't store a reference to a class in a data structure, or exploit polymorphism with its shared methods.


I believe that class methods in C++ behave similarly; this is one of the standard disadvantages of the standard implementations of Singleton. If you want polymorphic behavior, then you would want to use the Monostate version, which couples shared properties with object methods. In general, just what a Singleton should be is a matter of ongoing debate. A glib but reasonable resolution is that a Singleton should be what it needs to be -- overemphasizing the pattern is a case of the tail wagging the dog.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to