The big difference between a singleton and a bunch of static methods is that singletons can implement interfaces (or derive from useful base classes), so you can pass around the singleton as if it were "just another" implementation.
Static class:
Static class provides better performance than Singleton pattern, because static methods are bonded on compile time.
Static class always provides the eagerly loaded however Singleton classes can be lazy loaded if it’s a heavy object.
Singleton Objects:
Singleton Objects stored on heap while static class stored in stack.
Singleton Objects can have constructor while Static Class cannot.
Singleton Objects can dispose but not static class.
Singleton Objects can clone but not with static class (logically wrong to clone the Singleton objects).
No comments:
Post a Comment