Hi,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
>> I stumbled upon this piece of code (random pick) :<br>
>><br>
>> PMA_CommonFunctions::getInstance()->backquote($_REQUEST['view']['name'])<br>
>><br>
>> and it made me wonder if using a singleton for PMA_CommonFunctions is<br>
>> necessary, because basicaly PMA_Commonfunctions is a collection of<br>
>> methods, not really a 'living' object.<br>
>> So then I had a look at the class, and I discovered that the class has<br>
>> no class variables (apart from the _instance variable) and an empty<br>
>> constructor.<br></div></div></blockquote><div><br>Exactly, that class has no properties except _instance which needed for implement this pattern for refer to the class instance itself. So this is not a living object.<br>
<br>I search bit more in this kind of cases and get to know that, this kind of utility classes are making static. And it is faster than singleton class. From the both approaches our work can be done. But not the exact need for use singleton pattern here.<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="HOEnZb"><div class="h5">
>> So basicly this should be a static class, with static methods, because<br>
>> no instance is needed for it to work.<br>
>><br>
>> And the above piece of code will become :<br>
>><br>
>> PMA_CommonFunctions::backquote($_REQUEST['view']['name'])<br>
>><br>
>> BTW: If you convert it to a static class, don't forget to replace the<br>
>> $this->method() calls by the static equivalent self::method().<br></div></div></blockquote></div><br>I'll do the necessary modifications if others think this approach is good.<br><br clear="all">Regards !<br>
-- <br><font size="4">Chanaka Dharmarathna<br></font><div><font color="#999999"><b>Virtusa (Pvt) Ltd. | </b></font><b style="color:rgb(153,153,153)">Sri Lanka</b></div><br>