On Feb 21, 2006, at 8:59 PM, Charles Yeomans wrote:
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.
Fair comment. I would add: there are uses for both versions; and this
doesn't detract from the other excellent advantages of having first-
class classes.
On reflection, although I would greatly love to have real first-class
classes, with metaclasses and all that chewy goodness, such esoterica
*might* be outside the "user friendly" ambit of RB.
OTOH, they would let knowledgeable developers create classes and
frameworks that were easier for everyone to use.
I think an excellent RBish step would be for the properties of the
class in the Project pane to sport an extra entry: Shared Interfaces.
A regular class interface mentioned on that line would mean that the
shared methods satisfy that class interface, and that the *class*
could be treated as an instance of one of those objects.
*Particularly* if coupled with a "class constructor" method, this
would be a small change in the IDE and the language that would
simplify a great many things.
Again: sign on to bzvggysz if you agree.
Guyren G Howe
guyren-at-relevantlogic.com
http://relevantlogic.com
REALbasic, PHP, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training
_______________________________________________
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>