I read in some blogs that singleton hampers testing as it causes high coupling and mocks cannot be replaced in place of it, so the solution is to implement an interface and pass it around in arguments. I don't have links to blogs and will attach it as soon as I find it. But due to static
getInstance()
method that will not be possible.
So is there any advantage of implementing an interface in Singleton Pattern?
public interface SingletonInterface{
//some methods
}
public class Singleton1 implements SingletonInterface{
//Usual singleton methods
}