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.