Martijn Faassen wrote:

> I don't like the word singleton very much either. Singleton in the 
> Design Patterns book has a very particular implementation that is 
> criticized by a lot of developers and in particular that particular 
> pattern is very uncommon in the Python world (people just use globals). 
> I think introducing the term would pull in all that baggage to a 
> newcomer. Just type in 'singleton' in Google and you'll get the 
> wikipedia definition:
>    In software engineering, the singleton pattern is a design pattern
>    that is used to restrict instantiation of a class to one object.
> Utility classes are *not* restricted to a single instantiation. Now we 
> can argue successfully that's an extension of the singleton principle, 
> but then we've lost a lot of people already who thought they knew (or 
> went to lookup) what the word "singleton" means.

For the record, I normally use the singleton analogy to explain unnamed 
global utilities. Perhaps that's bad, though I find it works pretty 
well. It'd probably be more accurate to use the terms you did, an 
"extension of the singleton principle", but as you say, it just adds 
more complexity.

To me, the Singleton pattern says, "each time you ask for this, you get 
the same object". That's a little bit different from "this class can 
only be instantiated once". I think the important part of the design 
pattern is the shared instance (e.g. to conserve resources or to 
implement some kind of shared counting/tracking), not the restrictions 
on instantiation.

I'm certainly -1 on using the term in the ZCA. I think changing our 
nomenclature would be terrible for the same reasons I think changing (as 
opposed to extending/improving) our API would be terrible. Utilities are 
in one way a more specific concept (due to the lookup semantics) and in 
another way a more generic concept (since named utilities can be used to 
implement a registry of homogenous objects).


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See

Zope-Dev maillist  -
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to