I just thought the best way is to get rid of the public static getInstance () in Singleton. I do not want my Singleton classes to be accessible from every point in my program.
I thought that I have a static create () function that creates one object and returns it, but you cannot call this method twice.
But it is not very elegant for me. Than I would have to make a statement or throw an exception in case create () is called a second time.
Is there any other way to achieve what I want?
source
share