[quote name='Caburé' timestamp='1352472139' post='4999297']
METADATA:
There are many times when a program needs to store and reference data that is a result of processing and that can be used again. How will you store metadata? I like to use singletons for structural/constant data/flags/metadata(temporary) instances, when the complexity of creating new instances and having it loading its data from something/somewhere doesn't worth as simply acessing it straight like cache of processors is used and Windows Registry (always in memory).
sorry it doesn't float at all.
It doesn't have to be a ONE! You create it ONCE, and pass it around or publish it to objects interested in it.
You are talking about trading memory for computation costs.. it doesn't have anything to do with SINGLENESS and globality of scope.
[/quote]
Singleton is single instance. It does not necessarily mean global scope (you can create a singleton in the scope of a package, for example).
Singleton is static - that is why there is a static word in Java (and not, again, necessarily, a global pointer/variable).
If you could reraise the data of a singleton just by making a new instance without costs, what would be the reason to use static classes (singleton) - that is what I am explaining?
How would you store, for example, trigonometry tables? If you can't see that, every time you declare a public static final int, the class where you declared it becomes a singleton, conceptually: is accessible in global scope and has only one static instance - the class itself. In Java, you can even set/change static variables at runtime (but not final variables).
I just said how I like to use SingleTons : to store metadata. I didn't argue that it is the only way to do that. But.. ppl seem to be stuck in just one technique.
After all, I am posting in the wrong place, I forgot to tell that I was meaning Java as programming language.