100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Facade vs Adapter Pattern

Facade vs Adapter pattern explained — simplifying a subsystem vs bridging an interface mismatch — with Java code examples.

mediumQ161 of 226 in Object Oriented Programming Est. time: 6 minsLast updated:
Open Code Lab

Expected Interview Answer

A Facade pattern provides a single, simplified interface over a complex subsystem of multiple classes, while an Adapter pattern converts one existing interface into another interface that a client expects, and the key difference is intent: Facade simplifies, Adapter translates for compatibility.

Facade is used when a subsystem has many interacting classes with a complicated combined API, and you want to give callers one easy entry point that internally coordinates the subsystem — it doesn’t necessarily hide incompatibility, it hides complexity. Adapter is used when you have an existing class with an interface that doesn’t match what a client code expects (often a third-party library’s interface versus your application’s expected interface), and you wrap it in a class that translates calls from one shape to the other — the wrapped class usually has a single, comparable responsibility, just an incompatible signature. A Facade typically introduces a brand-new, simpler interface that didn’t exist before; an Adapter conforms an existing interface to match one that already exists on the client side. Both are structural patterns and both use composition/wrapping, which is why they’re commonly confused, but the trigger for choosing one over the other is whether you’re simplifying a many-class subsystem (Facade) or bridging a single interface mismatch (Adapter).

  • Facade: reduces coupling to a complex subsystem's many classes
  • Adapter: enables reuse of existing/third-party code without modifying it
  • Both: isolate change — subsystem or vendor library can evolve independently
  • Both: improve testability by letting you mock a single boundary

AI Mentor Explanation

A team manager (Facade) gives sponsors one single contact point instead of making them separately deal with the coach, physio, kit manager and media officer — the manager coordinates all of that complexity behind one simple request. A translator hired for an overseas tour (Adapter) instead solves a different problem: converting the coach’s English instructions into the exact language and format the local ground staff expect, with no simplification of complexity involved, just format conversion so two already-compatible parties can communicate.

Step-by-Step Explanation

  1. Step 1

    Diagnose the problem

    Facade: a subsystem has many classes and a complex combined API. Adapter: one existing interface doesn't match what a client expects.

  2. Step 2

    Design the wrapper

    Facade: build a new, simpler interface that coordinates the subsystem internally. Adapter: build a thin translation layer around a single existing class.

  3. Step 3

    Check the interface origin

    Facade introduces a brand-new interface. Adapter conforms to an interface that already exists on the client side.

  4. Step 4

    Verify the intent

    Facade: reduce complexity for callers. Adapter: enable reuse/compatibility without modifying the wrapped class.

What Interviewer Expects

  • Correct distinction: Facade simplifies a subsystem, Adapter bridges an interface mismatch
  • Recognition both are structural patterns using composition/wrapping
  • A concrete example of each pattern in a real codebase context
  • Awareness that Facade introduces a new interface while Adapter conforms to an existing expected one

Common Mistakes

  • Treating Facade and Adapter as interchangeable because both “wrap” something
  • Saying Facade is only for one class rather than a multi-class subsystem
  • Forgetting Adapter is triggered by an interface incompatibility, not by complexity
  • Not mentioning that both are structural design patterns

Best Answer (HR Friendly)

A Facade gives you one simple button that quietly coordinates a bunch of complicated moving parts behind the scenes — think of it as a simplified front door to a messy subsystem. An Adapter, on the other hand, is about compatibility: you take something that already works but speaks a different 'language,' and you wrap it so it fits the interface your code expects, without touching the original.

Code Example

Facade simplifying a subsystem vs Adapter bridging an interface
// FACADE: one simple entry point over a complex subsystem
class VideoConverterFacade {
    public File convert(String fileName, String format) {
        AudioMixer mixer = new AudioMixer();
        VideoCodec codec = new VideoCodec();
        BitrateOptimizer optimizer = new BitrateOptimizer();
        // coordinates several subsystem classes behind one simple call
        return optimizer.optimize(codec.encode(mixer.normalize(fileName), format));
    }
}

// ADAPTER: bridges an incompatible existing interface to the one the client expects
interface ModernLogger {
    void log(String message);
}

class LegacyLoggerLibrary { // third-party, cannot be modified
    void writeEntry(String text, int severity) { /* legacy behavior */ }
}

class LegacyLoggerAdapter implements ModernLogger {
    private final LegacyLoggerLibrary legacy = new LegacyLoggerLibrary();

    @Override
    public void log(String message) {
        legacy.writeEntry(message, 1); // translates the call shape
    }
}

Follow-up Questions

  • Can a Facade internally use an Adapter, and when would that make sense?
  • How does the Adapter pattern differ from the Decorator pattern?
  • When would you prefer a Facade over just documenting a complex subsystem well?
  • What is a class adapter versus an object adapter in Java, given no multiple inheritance?

MCQ Practice

1. The primary purpose of the Facade pattern is to?

Facade's goal is simplifying access to a multi-class subsystem behind one easy interface.

2. The Adapter pattern is triggered specifically by?

Adapter solves an interface-incompatibility problem, wrapping an existing class to match a different expected interface.

3. Which statement correctly distinguishes the two patterns?

Both are structural patterns, but Facade's interface is new and simplifying, while Adapter's interface already exists and must be matched.

Flash Cards

Facade in one line?A single simplified interface over a complex, multi-class subsystem.

Adapter in one line?A wrapper that converts one existing interface into another interface a client expects.

Key trigger difference?Facade: too much complexity. Adapter: interface incompatibility.

Do both use composition?Yes — both are structural patterns that wrap existing objects rather than modify them.

1 / 4

Continue Learning