In this blog, we will discuss Proxy Design Pattern, its example, and how it is different from the other design patterns. But, it’s important to have an understanding of the design patterns first. You can refer here.

What is a Proxy

A Proxy is something that has the authority to do some activity on behalf of the original object. For example, when you are busy for the day and you have to pay electricity bill. So, your approach would be like you will ask someone else to pay on behalf of you.

Proxy Pattern

In the proxy patterns, a class represents the functionality of another class. These type of design patterns comes under structural patterns. Here, we create an object having original object to interface its functionality to outer world.

Why we need Proxy Pattern

This proxy is helpful when we don’t want to manipulate our main object. It avoids the duplication of objects so less memory is used which turns out to increases the performance of the application. And one of the advantages of Proxy pattern is good security.

Example for Proxy Pattern

Let’s see how to write a program using the Proxy Pattern.

So we start by creating a simple interface.

public interface College  {

    public void attendance(String student) ;

}

#functional programming #java #tech blogs #design pattern #functional java #java #proxy design pattern

Proxy Design Pattern in JAVA
1.55 GEEK