ApplicationProperties not a singleton anymore?


#1

Hi,

I used to get my application properties doing:
PropertySet* const globalSettings = ApplicationProperties::getInstance()->getUserSettings();

It looks like the ApplicationProperties class is not declared as a singleton anymore (I use the last git version).
What is the correct way now to get my application properties from anywhere in my code?
It would be great to access it with something like JUCEApplication::getProperties()->getUserSettings()…

Thanks!

NB: the new “modules” refactoring rocks!


#2

Just a precision:
I could obviously declare an ApplicationProperties instance in my inherited JUCEApplication class, and make a static method to access it.
The problem is that I used to store ApplicationProperties in my audio plugin projects, which don’t have such Application class…


#3

I removed the singleton because
a) Singletons are bad.
b) In this case, many people wouldn’t even have been using the class as a singleton, so for many purposes it was useless functionality.

You can still use your own singleton to hold an ApplicationProperties object if you want to, it’s trivial to write that. You could even just have a static instance of a properties object.

[quote]It would be great to access it with something like JUCEApplication::getProperties()->getUserSettings()…
[/quote]

You can easily add an ApplicationProperties object to your own JUCEApplication subclass, but it’s not something that belongs in the base class, because not everyone will want one.


#4

Hey now! Don’t go bad mouthing singletons, or I’m gonna tell on you


#5

[quote=“TheVinn”]
Hey now! Don’t go bad mouthing singletons, or I’m gonna tell on you[/quote]

I never had a strong feeling about Singleton’s either way. But I work with a fellow who, really, acts out part of “Highlander”, shouting ‘There can only be ONE!!!’ whenever he declares one. After 9 years in the office next door, I might be developing an emotional aversion…