Design Patterns interview question · Most asked

Compare Adapter, Decorator, Proxy and Facade.

Summary

All four wrap something. Adapter gives an existing object a different interface so it fits; Decorator keeps the same interface and adds behaviour (stackable); Proxy keeps the same interface and controls access (lazy, permissions, remote); Facade offers a new, simpler interface over a whole subsystem.

Longer Answer

The code shape can be nearly identical (a class holding another and delegating), so the distinction is intent:

Pattern Interface Intent
Adapter different make it fit
Decorator same add behaviour
Proxy same control access
Facade new, simpler, over many classes simplify

Naming the wrapper by its intent tells the next reader why it exists.

Key Points

  • Adapter: fit a different interface.
  • Decorator: add behaviour, same interface.
  • Proxy: control access, same interface.
  • Facade: simplify a subsystem.

Deep dive: Design Patterns, Explained Simply: Choosing the Right Pattern

Explanation

What interviewers look for

Intent-based distinctions, not just structure.

Follow-up questions

  • Can one class be both a proxy and a decorator?

More most-asked Design Patterns questions

← All Design Patterns questions