[Catalyst] Re: using Plugin::Singleton and testing

A. Pagaltzis pagaltzis at gmx.de
Fri Nov 17 14:02:12 GMT 2006


* Daniel McBrearty <danielmcbrearty at gmail.com> [2006-11-17 12:00]:
> A global is something that is in the global namespace.
> A singleton isn't, any more than other class is. You have to
> import the class to which it belongs to use it.

That might be true in Java. It’s patently false in Perl.

> Until someone actually presents a solid reason why you should
> *never* have a class which can only have a single instance, the
> argument is going nowhere, as far as I can see.

No, I think the onus is the other way around. I’d like to hear
about a case that is much more sensibly be solved using
a singleton class rather than by other means of ensuring
uniqueness in a higher level of the infrastructure.

I don’t want to claim that there is no circumstance in which
singletons are useful; I argue with people who claim that every
use of GOTO is evil, too. But I doubt that singletons are even as
useful as GOTO, in practice.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Catalyst mailing list