Singleton pattern vs Class variables and methods

  • Thread starter Summercool Summercool
  • Start date
S

Summercool Summercool

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

Marcin Raczkowski

Summercool said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top