Design Patterns

Why can’t we use a static class instead of singleton?

Intention of a singleton pattern is to ensure that a single instance of a class is instantiated. So why not static class? Reasons are below :- – One of the key advantage of singleton over static class is that it can implement interfaces and extend classes while the static class cannot (it can extend classes, Read More →

Example of Singleton design pattern

In our previous post, we discussed about singleton design pattern. Now, we will see where is its applicability. According to the definition the singleton pattern should be used when there must be exactly one instance of a class, and when it must be accessible to clients from a global access point. Here are some real Read More →

Singleton Pattern – Java

Singleton Pattern

Singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The singleton pattern is one of the simplest design patterns. It involves only one class which is responsible to instantiate itself, to make sure Read More →