In this section of the course we're going to take a look at the proxy design pattern now a proxy is
really just an interface for accessing a particular resource.
But the key thing about the proxy is that its interface looks just like the interface of the object
that you are actually attempting to access.
So what is the motivation for using a proxy.
Let me give you one example let's suppose that you are calling food up bar say because an object foo
and you're calling the method bar on it.
Now this makes lots of assumptions.
So for example you're assuming that when you call food or bar the stuff that's in bar is going to happen
in the same process as the process you're actually in.
Now this might be OK for the time being but what if later on you decide that you want to put all the
food related operations into a separate process.
This might be a process on the same machine and could be a process on a remote machine somewhere it
could be something in the cloud.
Another question is well given that you want to put all of Barrs operations somewhere else is it really
possible to avoid changing your code in any significant way.
And this is precisely what the proxy actually gives you.
So the proxy basically gives you the same interface as the one that you've been using but it gives you
entirely different behavior behind the scenes.
So the kind of proxy that I've described here a proxy which looks like a local object but actually works
as a remote interface to some system somewhere else.
This is called a communication proxy and it's only one example of a large number of proxies that you
can build so you have different proxies available for things like logging you have virtual proxies you
have guarding proxies and so on and so forth.
And in this section of the course we're going to take a look at just a selection of some of the proxies
that people actually build for their development needs.
So here is the formal definition of a proxy so a proxy is quite simply a class that acts as an interface
to some resource or other and that resource might be remote.
It might be expensive to construct.
It might require some additional functionality like logging or something else to that effect and that
is why we build proxies.