In our data access layer at work we have this standard implementation where the class is accessed through a singleton public property which looks something like this:
public static CustomerController Instance
{
get
{
lock(singletonLock)
{
if( _instance == null )
{
_instance = new CustomerController();
}
return _instance;
}
}
}
now, I get what the code is doing, but I was wondering why you would do this over just creating an instance of the class each time it is used?