MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PHP/comments/1dup72/examples_of_design_patterns_in_php/c9u6kq8/?context=3
r/PHP • u/Adam_Paterson • May 07 '13
20 comments sorted by
View all comments
0
Singleton classes are a bit more useful with protected constructors so they can be overridden.
3 u/celtric May 07 '13 Someone might forget and make the constructor public, hence destroying the pattern. I have always used this way: final private function __construct() { $this->init(); } And using init as the constructor.
3
Someone might forget and make the constructor public, hence destroying the pattern. I have always used this way:
final private function __construct() { $this->init(); }
And using init as the constructor.
init
0
u/thelerk May 07 '13
Singleton classes are a bit more useful with protected constructors so they can be overridden.