Singleton
-
hi, I need a global store for storing error messages. It could be done using singleton. Now whats the difference between the following two. 1. Implement singleton pattern. 2. Creat a class. Make its contructor private. Expose the functionality using static functions. In singleton pattern a single object is created but in 2nd approach no object is created. Which approach is better ?? Thanks...
-
hi, I need a global store for storing error messages. It could be done using singleton. Now whats the difference between the following two. 1. Implement singleton pattern. 2. Creat a class. Make its contructor private. Expose the functionality using static functions. In singleton pattern a single object is created but in 2nd approach no object is created. Which approach is better ?? Thanks...
If there is no explicit need for an object instance, I find the use of all static members simpler. If you want to use it to persist data using the framework's builtin serialization, then you would need an object.