Compare Adapter, Decorator, Facade, and Proxy — they all "wrap".

Topic: design-patterns, Structural Patterns. Level: Intermediate.

Answer

All wrap an object but with different intent: - **Adapter**: changes the interface so incompatible types work together. - **Decorator**: keeps the interface, **adds behavior/responsibilities** (stackable). - **Facade**: introduces a **new simpler interface** over a complex subsystem. - **Proxy**: keeps the interface, **controls access** (lazy, security, remote, caching). Intent is the differentiator: convert (Adapter), enhance (Decorator), simplify (Facade), control (Proxy). ```text Pattern Same interface? Intent Adapter NO (converts) make incompatible interfaces work together Decorator YES add responsibilities dynamically (stack them) Facade NEW simpler one hide a complex subsystem behind one entry point Proxy YES control access (lazy load / auth / remote / cache) ```