Re: Why is a singleton pattern useful? In what circums...
Posted By:
Tudor_Girba
Posted On:
Friday, May 4, 2001 09:23 AM
The Singleton Pattern applies whenever you want to be sure that only one instance of a class will exist in your code. But let's say that if you own the code you write, you might now that, for example, there can only be one instance of a graphic manager. So you'll have a global instance. But, if you don't own the code (for example you work in a team) and you still want to exist only one instance of that graphic manager. What will you do? How can you enforce that "only" one instance? It's simple you apply the Singleton Pattern. You will gain two things:
1. you won't have to tell the other guys how to use your class
2. you will now for sure that there will be only one instance of that class.