Illusion and reality – the proxy pattern
Many of us have come across the term proxy server. At a large company, the Internet access is restricted by a proxy server. The company may provide access to work-related pages only. Social media sites may be blocked. The proxy server is the place where all these rules are built. It is a checkpoint. A proxy is a class, hiding the real thing. It essentially is an interface (not to confuse with Java interface) to an expensive object. The real object could possibly be a remote object.
The proxy pattern is used to implement cross-cutting concerns. A cross-cutting concern is:
- A functionality needed across many different modules of an application
- The functionality is not core to the application (it would be reused by another application too)
- The functionality is necessary in most application (you need it very much—at times simply cannot do without it)
You don't want to reinvent the wheel and reimplement the functionality every time. Security...