Category Archives: Java Programs

Flyweight Design Pattern in Java

In this post, We will talk and learn about the FlyweightDesign Pattern in Java. Key Points About Flyweight Design Pattern : Flyweight Design Pattern is mainly used to reduce the number of objects created and to decrease memory footprint and increase the performance of the application. This design pattern falls under structural pattern as you… Read More »

Proxy Design Pattern in Java

In this post, We will talk and learn about the Proxy Design Pattern in Java. Key Points About Proxy Design Pattern : The Proxy pattern helps us to create an intermediary that acts as an interface to another resource and also hiding the underlying complexity of the application. Proxy means ‘in place of’, representing’ or ‘on… Read More »

Facade Design Pattern in Java

In this post, We will talk and learn about the Facade Design Pattern in Java. Facade design pattern is used to help the client applications; it doesn’t hide subsystem interfaces from the client. Whether to use Facade or not is completely dependent on the client application. We can apply Facade design pattern at any point… Read More »

Decorator Design Pattern in Java

In this post, We will talk and learn about the Decorator Design Pattern in Java. Decorator design pattern comes under structural design patterns. Decorator design pattern is used to modify the functionality of an object at runtime. At the same time, other instances of the same class will not be affected by this, so individual object gets… Read More »

Adapter Design Pattern in Java

In this post, We will talk and learn about the Adapter Design Pattern in Java. The Adapter design pattern falls one under structural design pattern It is used so that two unrelated interfaces can work together. The object that joins these unrelated interfaces is called an Adapter. Adapter Design Pattern Example in JDK : java.io.InputStreamReader(InputStream) java.io.OutputStreamWriter(OutputStream) javax.xml.bind.annotation.adapters.XmlAdapter#marshal() and #unmarshal()… Read More »

Builder Pattern in Java

In this post, We will talk and learn about the Builder Pattern in Java. There are mainly three major problems with Factory and Abstract Factory design patterns when the Object contains a lot of attributes. We have to pass too many arguments from the client program to the Factory class that can be error-prone because most… Read More »

Abstract Factory Pattern in Java

In this post, We will talk and learn about the Abstract Factory Pattern in Java. Abstract Factory pattern is almost similar to Factory Pattern except for the fact that it’s more like a factory of factories. Abstract factory pattern we can consider as another layer of abstraction over factory pattern. Whenever you need another level of abstraction over a group of… Read More »

Factory design pattern in java

In this post, We will talk and learn about the Factory design pattern in java. Factory pattern comes under a creational design pattern. It is one of the most used design patterns in Java. Using this design pattern we can create an object without exposing the object creation logic to the client and refer to the… Read More »

Prototype Pattern in Java

In this post, We will talk and learn about Prototype Pattern in Java. Prototype comes under a creational design pattern that makes use of cloning objects if object creation complex and time-consuming. Below is the complete source code: Student.java Model class

StudentDAO.java creates Cloned Object that makes use of  Prototype Pattern:

Test.java Client Program:

Output… Read More »