[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Singleton pattern vs Class variables and methods

SpringFlowers AutumnMoon

9/16/2007 4:43:00 PM

There seems to be a big thing about the Singleton Pattern... and the way
to implement it, but what about just using class variables and class
methods to do the job?

So for example, the class Jukebox can have an object Logger... and all
the Jukebook instances will call the Logger methods which access the
class variables... isn't that what the Singleton Pattern is?

(this refers to p.35 of the pickAx2 book... about creating a class that
can do the singleton by making "new" private.)
--
Posted via http://www.ruby-....

1 Answer

Marcin Raczkowski

9/16/2007 4:53:00 PM

0

Summercool Summercool wrote:
> There seems to be a big thing about the Singleton Pattern... and the way
> to implement it, but what about just using class variables and class
> methods to do the job?
>
> So for example, the class Jukebox can have an object Logger... and all
> the Jukebook instances will call the Logger methods which access the
> class variables... isn't that what the Singleton Pattern is?
>
> (this refers to p.35 of the pickAx2 book... about creating a class that
> can do the singleton by making "new" private.)

It's singleton is PATTERN, implementation is left to progammer, in Ruby
you can implement singleton by including Singleton Mixin or using Class
and class variables (which is bit slower)