Proxy Design Pattern in Java
Gang of Four Definition: Provide a surrogate or placeholder for another object to control access to it. Computer World Example: Consider an ATM implementation for a bank. Here we will find multiple proxy objects. Actual bank information will be stored in a remote server. We must remember that in the real programming world, the creation of multiple instances of a complex object (heavy object) is very costly. In such situations, we can create multiple proxy objects (which must point to an original object) and the total creation of actual objects can be carried out on a demand basis. Thus we can save both memory and creational time. Explanation: In the following program, we are calling the doSomework() function of the proxy object, which in turn calls the doSomwork() of the concrete object. With the output, we are getting the result directly through the concrete object. For this example, I have created different packages, proxy implementations will be reside in ...