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

A. Pagaltzis pagaltzis at gmx.de
Fri Nov 17 02:08:35 GMT 2006


* Daniel McBrearty <danielmcbrearty at gmail.com> [2006-11-16 01:35]:
> a wonderful rant. except : he doesn't answer one basic question
> - what do you do when you genuinely do want only one instance
> to ever exist?

A singleton is nothing but a global variable, except the
identifier comes from the class namespace rather than the
variable namespace. Put it in a global variable already.

> "print spooler" is a crap example. A much better one is an
> audio player - you can only listen to one audio track at
> a time, you really don't want a second one to EVER happen. This
> is a reasonabvle design decision to make early for some
> systems. If you want to change the behaviour one day, that's
> irrelevant.

I still wouldn’t want to place the knowledge that there can only
be one audio stream in the audio stream class itself. That is
knowledge that belongs in the app, at least one level higher than
the audio stream class.

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



More information about the Catalyst mailing list