When to use Static class & when to use Singleton pattern?

With the singleton pattern, you get several advantages.

  • First, a singleton can extend classes and implement interfaces, while a static class cannot. See an example here.
  • Singleton class can be passed as a parameter while a static class cannot be.
  • Singleton class can be loaded lazily/asynchronously when needed while static class is always loaded.
This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. For more information - please visit our private policy.