mariarahat / bungeni-editor

Automatically exported from code.google.com/p/bungeni-editor
2 stars 0 forks source link

True Singleton classes #94

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is not an issue as such but just a minor observation.

Most of the classes considered to be Singleton classes are not truly Singleton. 
To ensure that we adhere to the true specifications of creating Singleton 
classes, we may need to do the following:

- Always make sure that the class constructor is made private to prevent client 
objects from creating instances of the class by invoking its constructor. At 
the same time, other methods inside the class will have access to the private 
constructor.

- Provide a public interface, in the form of a static method 'getInstance()', 
for clients to be able to get access to an instance of the class. This public 
method must be static for a client to be able to access this method without 
having to instantiate the class.

The second requirement has been met in most of the classes and not the first. 
So whenever you are going through the code, kindly make the changes  wherever 
the developer might have not. 

Original issue reported on code.google.com by fraogo...@gmail.com on 22 Nov 2011 at 3:11