In the way that I do things, I believe that there's no use for an abstract singleton. This is because 1) What you want to be a singleton is the final class you instantiate for use within the application whether it'd be a library, model, controller or view and NOT the abstract 2) Adding the singleton method is easy and can be written in 8 lines. See below protected static $_instance; public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } self::$_instance; } 3) PHP 5.3 below version doesn't support late static binding.
This will result in instantiating the abstract class instead of the final class inheriting it and will not function as expected, as already mentioned by Gordon and nuqqsa. So, for backward compatibility, better avoid it.
In the way that I do things, I believe that there's no use for an abstract singleton. This is because, 1) What you want to be a singleton is the final class you instantiate for use within the application whether it'd be a library, model, controller or view and NOT the abstract. 2) Adding the singleton method is easy and can be written in 8 lines.
See below. Protected static $_instance; public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } self::$_instance; } 3) PHP 5.3 below version doesn't support late static binding. This will result in instantiating the abstract class instead of the final class inheriting it and will not function as expected, as already mentioned by Gordon and nuqqsa.So, for backward compatibility, better avoid it.
The implementation of the singleton pattern must satisfy two requirements: It must provide a mechanism to access the singleton class instance without creating a class object It must persist the singleton object so that it is not instantiated more than once As long as that's provided, the variations are multiple. There's nothing wrong with making the class abstract extending from another abstract, if that's what you need. BUT, as @Gordon says, be aware that overriding static methods/properties causes peculiar behaviours in PHP.
Abstraction and interfaces are two very different tools. The are as close as hammers and drills. Abstract classes may have implemented methods, whereas interfaces have no implementation in themselves.
Abstract classes that declare all their methods as abstract are not interfaces with different names. One can implement multiple interfaces, but not extend multiple classes (or abstract classes). The use of abstraction vs interfaces is problem specific and the choice is made during the design of software, not its implementation.
In the same project you may as well offer an interface and a base (probably abstract) class as a reference that implements the interface. Why would you do that? Let us assume that we want to build a system that calls different services, which in turn have actions.
In the way that I do things, I believe that there's no use for an abstract singleton. This is because.
The implementation of the singleton pattern must satisfy two requirements.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.