Re: Singletons



Sasa wrote:
Hi,

What would in your opinion be the justified case for singletons?

I have seen (and written :-( ) code which relies far too heavily on
singletons and this cannot bring anything good. At this point in time,
I'm somewhat on the other extreme - I'm not sure at all if singleton is
good idea in any situation.

Which examples would you provide as appropriate for singletons?

Regards,
Sasa

I agree singletons and statics get used wrongly, I know I did.
Nevermind singletons, even statics can become a problem, now I prefer
to pass everything around, its more work but it's also more flexible.

The only 3 legit. singleton cases I've come across are:- 1) JNDI single
point of call, 2) Sequential PrimaryKey generator for use with
databases, 3) Game engines

1 and 2 must be singletons across all machines, all processes, all JVMs
.... Interestingly the simple GoF mechanism that uses statics and
private contructors will not work in these very cases that actually
need to be true singletons!

3. "Games". You can only have one game running per graphics context
(card).

Cheers.

.



Relevant Pages

  • Re: Beginner help - txt dungeon
    ... In my own simple Ruby adventure game ... I haven't myself implemented them as singletons as I ... A map can easily be ...
    (comp.lang.ruby)
  • Re: Architecture OOD
    ... > With a good overall design, there should never be any need to scrap ... scrap a game is because of coupling, so that to redesign one part ... >> these interfaces and in that way we know that what we have written ... Singletons are undesirable because they are global and they create ...
    (rec.games.roguelike.development)
  • Re: You be the judge
    ... I don't blame either player. ... These hands are a combined 22 HCP and ... it's only the two singletons that make game possible. ... did, because from either point of view, game is only about 25% likely. ...
    (rec.games.bridge)
  • Re: You be the judge
    ... I don't blame either player. ... These hands are a combined 22 HCP and ... it's only the two singletons that make game possible. ... did, because from either point of view, game is only about 25% likely. ...
    (rec.games.bridge)
  • Re: When is it appropriate to use static methods?
    ... statics are simplified equivalents of singletons. ... globals - functions or variables. ...
    (microsoft.public.dotnet.languages.csharp)