Factory Pattern in Java

Factory pattern lets a class defer instantiation to subclasses.   Factory pattern is useful when we have several concrete classes being instantiated and decision of the class to instantiate is made at runtime based on some conditions.     In Factory pattern, we create objects without exposing the creation logic to the client and refer […]

Observer Pattern in Java

The Observer pattern defines one to many relationship between a group of objects so that when one object changes state, all of its dependents are notified.     There two types of actors here : “Subject and Observers” The Subject manages some sort of data and the Observers should be updated when the data changes. […]

Singleton Design Pattern in Java

In this article, we will discuss :   – What is Singleton design pattern ? – How to implement Singleton design pattern in java ? – Effects of multithreading on singleton pattern – Implementing Double checked locking for singleton – Eager instantiation of singleton – Ways of breaking singleton – Uses of Singleton pattern – […]

Liskov Substitution Principle photo

Liskov Substitution Principle

In this article, we will discuss about Liskov Substitution Principle and how to implement it in Java.   What is Liskov substitution principle (LSP) ?   The Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called (strong) behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote […]

Interface Segregation Principle

Interface Segregation Principle

In this article, we will discuss about Interface Segregation Principle and how to implement it in Java   What is Interface Segregation principle (ISP) ? The interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use.   ISP splits interfaces which are very large into smaller and […]