Singleton pattern vs Class variables and methods

Discussion in 'Ruby' started by Summercool Summercool, Sep 16, 2007.

  1. 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/.
    Summercool Summercool, Sep 16, 2007
    #1
    1. Advertising

  2. 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)
    Marcin Raczkowski, Sep 16, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGlmZmlkZW50?=
    Replies:
    5
    Views:
    462
    Bruce Barker
    Jan 13, 2006
  2. Wilhelm
    Replies:
    1
    Views:
    164
  3. Kenneth McDonald
    Replies:
    5
    Views:
    313
    Kenneth McDonald
    Sep 26, 2008
  4. Ralph Shnelvar
    Replies:
    29
    Views:
    772
    David Masover
    Nov 30, 2009
  5. Charles Oliver Nutter

    Singleton methods without the singleton class

    Charles Oliver Nutter, Mar 15, 2010, in forum: Ruby
    Replies:
    4
    Views:
    202
    Charles Oliver Nutter
    Mar 22, 2010
Loading...

Share This Page