Tag Archives: Design Patterns

Behavioral Patterns

BEHAVIOURAL PATTERNS : These design patterns are specifically concerned with communication between objects. Chain of Responsibility : Chain of Responsibility is a behavioral design pattern that lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler Read More →

Creational Design Patterns

CREATIONAL PATTERNS These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. This gives program more flexibility in deciding which objects need to be created for a given use case. SINGLETON PATTERN : In object-oriented programming, a singleton class is a class that Read More →

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 →