Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #3705

Re: Singleton quintessence

From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
Newsgroups comp.programming
Subject Re: Singleton quintessence
References <179c6d53-7d84-438d-8047-b7fd8038a2cf@googlegroups.com> <bkln291pdrsb15dk4pejf2j4kndtb2a7kt@4ax.com>
Message-ID <BGTWt.14386$tv5.8908@fx29.iad> (permalink)
Date 2013-09-07 22:12 -0700

Show all headers | View raw


On 9/7/13 6:49 PM, Geoff wrote:
> On Sat, 7 Sep 2013 18:36:39 -0700 (PDT), bob <bob@coolfone.net> wrote:
>
>> So, I was asked in an interview to name a situation where you would use a singleton.  I was at a loss for coming up with a "good" answer.
>>
>> Anyone know of a "good" answer as to when you would use a singleton?
>>
>> Thanks.
>
> So, you are interviewing for a job in which it is important to know a
> technical subject in which you have no expertise and you want someone
> to feed you the answers so you can pass the test?
>
> Is this what you did in school too?
>
> I'm so glad you're working hard at cribbing and cheating on your
> exams. It makes me so happy for the future of the world to see
> induhviduals like you getting highly paid jobs in engineering.
>

There is rarely a good reason to use a singleton.  There are some 
though. In resource-constrained environments, a singleton can reduce 
footprint.  If you have a class whose state must exist only once in a 
running instance of your program, then a singleton is what you would use.

This is almost never the case, and it would be better to have a 
framework that manages the lifecycle of that object, such as any of the 
common IoC containers (Spring, Symfony, and more).

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Singleton quintessence bob <bob@coolfone.net> - 2013-09-07 18:36 -0700
  Re: Singleton quintessence Geoff <geoff@invalid.invalid> - 2013-09-07 18:49 -0700
    Re: Singleton quintessence Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-09-07 22:12 -0700
  Re: Singleton quintessence Ney André de Mello Zunino <zunino@softplan.com.br> - 2013-09-09 14:17 -0300
    Globals/"static" access in OO languages. (Was: Singleton quintessence) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-09-09 15:09 -0700
      Re: Globals/"static" access in OO languages. (Was: Singleton quintessence) Richard Damon <Richard@Damon-Family.org> - 2013-09-14 14:14 -0400
        Re: Globals/"static" access in OO languages. (Was: Singleton quintessence) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-09-14 11:31 -0700
          Re: Globals/"static" access in OO languages. (Was: Singleton quintessence) Robert Miles <milesrf@Usenet-News.net> - 2013-09-14 23:50 -0500
            Re: Globals/"static" access in OO languages. (Was: Singleton quintessence) Ian Collins <ian-news@hotmail.com> - 2013-09-15 17:18 +1200
  Re: Singleton quintessence "Charles Richmond" <numerist@aquaporin4.com> - 2013-09-10 17:34 -0500
  Re: Singleton quintessence Öö Tiib <ootiib@hot.ee> - 2013-09-14 11:34 -0700

csiph-web