Course contentsShow
← Software Engineering
Lesson 278 of 1,9338. Structural Design PatternsFree lesson

Types of Proxies: Virtual, Protection, and Remote

Learn the different proxy variants including virtual (lazy loading), protection (access control), and remote proxies.

Types of Proxies: Virtual, Protection, and Remote

You'll learn the three most common proxy variants and how each solves a specific access-control or performance problem.

The Three Proxy Flavors

Now that you understand the Proxy Pattern's core concept (a stand-in object controlling access to another), let's explore its three main types. Each variant exists to solve a different problem, but all share the same structural approach: placing an intermediary between client and real object.

Virtual Proxy (Lazy Loading)

A virtual proxy delays creating or loading an expensive object until it's actually needed. Think of it like a movie streaming service: you don't download the entire film upfront—you load it on-demand when you press play.

Use case: Loading large images, database connections, or heavy resources only when accessed.

Protection Proxy (Access Control)

A protection proxy checks permissions before allowing operations. Imagine a security guard at a building entrance who verifies your badge before letting you through.

Use case: Enforcing read-only access, validating credentials, or implementing role-based permissions before calling the real object's methods.

Remote Proxy (Location Transparency)

A remote proxy represents an object in a different address space—perhaps on another server or process. It handles network communication behind the scenes. Think of it like calling a friend: you dial their number (proxy), but the phone system handles routing your call across the network to their actual phone (real object).

Use case: Distributed systems, web services, or any scenario where the real object lives elsewhere but you want to work with it as if it were local.

Choosing the Right Proxy

Each proxy type addresses a specific concern: performance (virtual), security (protection), or distribution (remote). You might even combine them—a remote proxy that also does lazy loading!

Key Takeaway: Virtual proxies optimize resource loading, protection proxies enforce access rules, and remote proxies hide network complexity—all using the same structural pattern.