Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Singleton pattern vs Class variables and methods

Reply
Thread Tools

Singleton pattern vs Class variables and methods

 
 
Summercool Summercool
Guest
Posts: n/a
 
      09-16-2007
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/.

 
Reply With Quote
 
 
 
 
Marcin Raczkowski
Guest
Posts: n/a
 
      09-16-2007
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)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Singleton methods without the singleton class Charles Oliver Nutter Ruby 4 03-22-2010 10:46 PM
Class variables, instance variables, singleton; Ruby v. C++ Ralph Shnelvar Ruby 29 11-30-2009 07:43 PM
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
Singleton classes and Singleton pattern Wilhelm Ruby 1 10-11-2006 01:08 PM
Class based on singleton pattern and instance methods in that clas =?Utf-8?B?RGlmZmlkZW50?= ASP .Net 5 01-13-2006 08:45 PM



Advertisments