The word proxy reminds me of faking someone and marking there attendance in collage days 😅 . Unless there is a requirement for direct interaction with college officials, I can continue being his proxy (Marking his attendance).

Example 2: When you learn, you create short notes, flash cards etc. You use them to revise during exams, rather than going to through the entire text book(unless and until you can’t recall the topic). In this case, the short notes, act as a proxy for your text book.

A Proxy can also be defined as a surrogate. In the real world, a cheque or credit card is a proxy for what is in our bank account. It can be used in place of cash, which is what is needed, and provides a means of accessing that cash when required. And that’s exactly what the Proxy pattern does — controls and manage access to the object they are “protecting”.

Proxies have all sorts of uses: remoting, lazy loading, caching etc

Proxy means ‘in place of’, representing’ or the authority to represent someone else, or a figure that can be used to represent the value of something. Proxy design pattern is also called surrogate, handle, and wrapper.

  1. Picasso : Here, the image library, caches a compressed version of image on the system, and uses this where ever needed. The real image is fetched from the URL again, only if there is an updation for the image.
  2. Firebase : Firebase creates a local copy of the database. If the connection is lost in the middle, the library uses the local copy ie the proxy. When the connection is up again, the necessary syncing is performed.
Proxy is used when ever possible as an alternative to Internet

Say for example, you are using your college internet(Wi-Fi). In order to access your Attendance Portal, you have to enter college-domain URL. Sometimes you need to access things in as well. Accessing is far more expensive as it involves creating a secured connection to external network. So unless and until it is really necessary, we use the proxy version of Internet. (Hypothetical example 🐵 )

  1. Lets create the Proxy Class which will be instantiated when ever required.

2. Create the Real Internet, which is expensive but authentic.

3. Create a Driver class for testing.

Found it Interesting?
Please show your support by 👏. To read the complete series, click below.

I myself, has just started learning, design patterns. If you find any issues please feel free to post them in the comments section below. Thank you for reading so far 😄

Writes on Big Data, AWS & Backend technologies.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store