Recent questions in one of the newsgroups, regarding practical examples of Static instances. I’m sure there are many ideas out there, here is my take
Normally you would need to create a static instance when the secondary ( the primary ofcourse is the busines logic) need is -
1. Keeping an instance which holds the state of the application, while all other objects around this one in the application can live and die at will ( eg. the Request/ Application objects in ASP.Net which are static.)
2. To remove the overhead of creating and collecting objects which are more or less expected to be stateless ( consider the case of a remoting server/webservice providing math functions, totally stateless, and hence the service should mask a singleton/static instance that provides the services , thus avoiding the creation and collection of the objects created, one each for each call.)
The question sometimes raised is whether singleton is really better than static. Situational, is it?