<aside>

This section is part of the 5-hour LLD course by Mukul Raina

SLIDE 54: Section Intro: Structural Design Patterns

Section 5: Structural Design Patterns

Structural patterns address how classes and objects are composed to form larger structures. While creational patterns (Section 4) solved how objects are created, structural patterns solve how objects are connected and how their interfaces relate to each other. These patterns let you fit together classes that were not originally designed to work with each other, add behavior to objects without modifying their source code, and simplify complex subsystems behind clean facades.

What We Will Cover

  1. Adapter: integrating incompatible interfaces without modifying either
  2. Decorator: adding behavior dynamically without subclassing
  3. Facade: simplifying complex subsystems behind a clean interface
  4. Proxy: controlling access, lazy loading, and caching

Where Structural Patterns Appear in LLD Interviews

Interview Signal Structural Pattern Why
“Integrate with a third-party API that has a different interface” Adapter Bridge incompatible interfaces
“Add logging/caching/validation without modifying the core class” Decorator Layer behavior dynamically
“This subsystem has 6 services, simplify the API” Facade One entry point for complex coordination
“Control access to this expensive resource” Proxy Lazy loading, caching, access control
“We might swap this external dependency later” Adapter Isolate your code from external changes

<aside>

Mukul Raina | youtube.com/@mukulraina | slides.mukulraina.com | LinkedIn

</aside>


SLIDE 55: Adapter: Integrating Incompatible Interfaces

The Adapter pattern allows two classes with incompatible interfaces to work together by wrapping one class in a translation layer. The adapter converts the interface of the wrapped class into the interface that the calling code expects.

When You Need an Adapter

You need an Adapter when your code depends on an interface, but the concrete implementation you want to use has a different method signature, different parameter types, or a different return type. This happens most commonly when integrating third-party libraries, legacy systems, or external APIs whose interfaces you cannot modify.

The Structure

image.png