Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Singleton pattern vs Class variables and methods (http://www.velocityreviews.com/forums/t844118-singleton-pattern-vs-class-variables-and-methods.html)

Summercool Summercool 09-16-2007 04:42 PM

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.)
--
Posted via http://www.ruby-forum.com/.


Marcin Raczkowski 09-16-2007 04:52 PM

Re: Singleton pattern vs Class variables and methods
 
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)



All times are GMT. The time now is 04:49 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.