Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.


YOU ARE HERE: HOME Questions Whats the difference between Static class and Singleton instance

Static Class vs Singleton Instance

View(s): 22282

Whats the difference between Static class and Singleton instance?

Answer 1)

From architectural standpoint: It is not possible to pass static class between two layers or tiers as we can neither pass static class as parameter to any method nor return from any method.

Here are some examples where we go with singleton implementation as they can’t be achieved using static classes

  1. Controlled/lazy initialization - Create the instance explicitly or only when it is needed (which is sometimes necessary because construction may depend on other information).
  2. Destruction - Deterministically free the resources acquired by the instance.
  3. Type - Define the contract by an interface or base class and create the singleton via a factory.
  4. Testing - Unit testing the singleton class (e.g. recreate a clean instance for each test) as well as replacing it by a mock object.
  5. Scope - Static classes are limited to "1 instance per app domain". Singletons can have different scopes, e.g. instance per thread, per request, per whatever.
  6. Code artifacts - Singletons allow for events and properties.


  Asked in:  Deloitte   Expertise Level:  Expert
  Last updated on Friday, 24 June 2011
4/5 stars (15 vote(s))

Register Login Ask Us Write to Us Help