in reply to Re^3: Log::Log4perl and singleton design issue
in thread Log::Log4perl and singleton design issue

Yes, but you make it function accessable so you can create two, one or three on a whim. The singleton pattern allows control over that.

----
Give me strength for today.. I will not talk it away..
Just for a moment.. It will burn through the clouds.. and shine down on me.

  • Comment on Re^4: Log::Log4perl and singleton design issue

Replies are listed 'Best First'.
Re^5: Log::Log4perl and singleton design issue
by BrowserUk (Patriarch) on Dec 19, 2004 at 21:13 UTC
    ... so you can create two, one or three on a whim. The singleton pattern allows control over that.

    1, 2 or 3 instances of a singleton ... m'kay :)


    Examine what is said, not who speaks.        The end of an era!
    "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
    "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

      You don't create multiple instances, jsut multiple references. Each part of the program that needs a reference gets its own, so it doesn't have to rely on some other distant part of the program.

      For instance, Apache::DBI does this sort of thing so different things happening in mod_perl can share a database connection, even though they might be different applications.

      --
      brian d foy <bdfoy@cpan.org>
      The point is not to hardcode something somewhere. If you wish to use globals, go right ahead. I'm not trying to stop you. Just like you use enapsulation in OO for setters and getters for the flexibility of doing things during sets or gets, it's the same for singletons. It allows you to break the mold. Saying singleton's are useless is like saying sed is useless. If it were useless, people wouldn't use it.

      ----
      Give me strength for today.. I will not talk it away..
      Just for a moment.. It will burn through the clouds.. and shine down on me.

        If it were useless, people wouldn't use it.

        Can you make the same argument about neckties?

        Neckties are useless, but some people think wearing them makes them more professional.

        -sauoq
        "My two cents aren't worth a dime.";