Mike Simmons wrote:I would think that static variables are just as thread-safe (or not) as instance variables in a singleton.
Ranjan Maheshwari wrote:Why would one ever require one and only one instance? Same purpose can be achieved using classes with static member variables and static methods.
Jeff Verdegan wrote: there is a difference between a true singleton object and a non-instantiable class full of only static methods: Polymorphism.
Jeff Verdegan wrote: the Principle Of Least Surprise.
Ranjan Maheshwari wrote:
Jeff Verdegan wrote: the Principle Of Least Surprise.
What's the Principle Of Least Surprise?
Ranjan Maheshwari wrote:
Jeff Verdegan wrote: there is a difference between a true singleton object and a non-instantiable class full of only static methods: Polymorphism.
Can someone give me examples from Real life scenarios where Singleton objects will take part in polymorphism?
But if you want to replace static methods with instance methods on multiple instances, the client will be forced to change their code to match your changing API.