Singleton pattern vs Class variables and methods

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.)

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)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs