[Phpmyadmin-devel] about $common_functions

Marc Delisle marc at infomarc.info
Tue Jul 3 15:51:54 CEST 2012

Le 2012-07-03 09:38, Rouslan Placella a écrit :
> On 03/07/12 14:34, Marc Delisle wrote:
>> Hi,
>> I just made a suggestion to Thilina but I want to validate it with
>> everyone.
>> I see a lot of
>> $common_functions = PMA_CommonFunctions::getInstance()
>> inside many functions of the same library. If we know that this library
>> is always called from one script, I believe it would be more efficient
>> to do this instead, inside the functions:
>> global $common_functions;
>> and ensure that $common_functions has been defined in the global scope
>> of the calling script.
> Doesn't that defeat the purpose of having a singleton class?

Well, I don't understand the definition of a singleton. From [0],
"the singleton pattern is a design pattern that restricts the
instantiation of a class to one object"

Does that mean that one such object must exist inside a function, or
must exist considering all scopes?

[0] http://en.wikipedia.org/wiki/Singleton_pattern

Marc Delisle

More information about the Developers mailing list