Alternative to singleton for unique resources
Posted
by
user1320881
on Stack Overflow
See other posts from Stack Overflow
or by user1320881
Published on 2012-04-15T22:49:13Z
Indexed on
2012/04/15
23:30 UTC
Read the original article
Hit count: 165
I keep reading over and over again that one should avoid using singletons for various reasons. I'm wondering how to correctly handle a situation where a class represents a unique system resource. For example, a AudioOutput class using SDL. Since SDL_OpenAudio can only be open once at a time it makes no sense having more then one object of this type and it seems to me preventing accidentally making more then one object would actually be good.
Just wondering what experienced programmers think about this, am i missing another option ?
© Stack Overflow or respective owner