Thread:Talk:Requests for comment/Configuration database/Singletons/reply

Singletons do provide a few significant advantages over a set of globals or a global array. Mainly:
 * Related functions can be stored and referenced together by being in the same class (rather than being put in random utility classes or global functions)
 * Input/Output Read/Write is controlled rather than on the loose. A get/set function (either one-for-all or more specifically) can limit/verify/validate the input (ie. throw exception or correct value when it doesn't validate, instead of having to sanity check every time we access the configuration variable since it could be set to anything...)
 * likewise the read function is able to limit reading values based on the context or moment in execution time (ie. before hook X is fired, or if variable Y is set to Z)
 * They are one step closer to an even better system.

I agree though that Singletons, when used as such, are much like globals. A better way would perhaps be a static cache of instances, ie. like  instead of   which would either load it or get it from static cache, where   would be like   using   which would be set during initialization of the wiki/run.