Singelton pattern
Singelton pattern is required where we need single instance of class. Example in financial domain applications there is major requirement of security and class need to have single instance and no other can use same instance of the class.
We define singelton pattern as – Ensure a class has only one instance and provide a global point of access to it.
It is achieved by creating 1) Private constructor 2) Static methods.
Example
public class singelton
{
static singelton objSingle;
private singelton()
{
}
public static singelton print()
{
if(objSingle == null)
{
objSingle = new singelton();
}
return objSingle;
}
}
