DELAPARRA
Index
Color
NL
Category: Design patterns

Proxy

Explained by Updated

What is Proxy?

Proxy: Provide a surrogate that controls access to another object — add lazy initialisation, access control, logging, or caching transparently. The Proxy pattern puts a stand-in object in front of a real one. The proxy has the same interface, so callers do not notice, but it can add behaviour before or after passing calls through.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Proxy

How is Proxy used in practice?

Typical uses are lazy loading, where an expensive object is only created when first used; access control, where the proxy checks permissions; caching, where repeated calls are answered without reaching the real object; and logging.

What should you keep in mind with Proxy?

You meet proxies often without naming them. ORMs use lazy-loading proxies for related records, and HTTP reverse proxies like Nginx apply the same idea at network level. In code, keep proxies thin and focused on one concern. If a proxy starts adding business rules, it has become something else and should be named accordingly.

At a glance

CategoryDesign patterns
Explained by
Updated

More Design patterns terms

All terms starting with P

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.