Hi,

Just a quick note: there are many real-life situations that one would want singletons to be different based on the arguments.  In pattern-speak, this is usually referred to as an object registry, and qooxdoo does this to garbage collect its objects, but a hybrid singleton/object registry makes sense sometimes.

For a real-life example, a program I wrote in PHP uses a configuration object that is a singleton per-directory, so that if one requests a configuration object that is for an existing configuration, it retrieves the in-memory configuration if it has already been loaded, and otherwise creates a new object and loads the configuration from disk.  To differentiate from a singleton, I used a different method name, however, because it would be confusing to those who would read "singleton" and assume it operates as a normal singleton.

Of course, one needs to look long and hard at ANY use of a singleton, there are all kinds of hidden pitfalls.  If possible, it's far better to redesign to avoid singleton at all.  Most knee-jerk examples of a singleton are simply not good design and can be handled instead through some form of composition or delegation instead.

Greg
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to