So one question that you might have is considering that the proxy pattern and the decorator pattern
are so similar that what exactly is the difference between the two.
Well the key difference is that the proxy tries to provide an identical interface whereas the decorator
tries to enhance that interface so a proxy like for example typical communication proxy for example
would try to stick to the exact interface that you already have so that you wouldn't have to actually
rewrite any code whereas the decorator also tries to provide part or the whole of the interface that
you're actually decorating.
However the decorator typically gives you additional features as well it could be additional fields
additional member functions what have you.
Now in terms of the implementation what happens is that the decorator typically aggregates or has a
reference to what exactly it's decorating and the proxy doesn't have to do that.
The proxy can be a brand new object not related to the underlying object at all it has to do is just
masquerade as that object that you've been working with.
Now the interesting thing about the proxy on like a decorated object is it might not even be materialized
it might not even exist so you might have a proxy over something which hasn't been constructed.
And we certainly looked at how that can be made possible if you have a virtual proxy for example.