What's the difference between what the Facade pattern and the Adapter pattern are each trying to solve?
Adapter solves an incompatibility problem: two interfaces don't match, and the adapter translates one shape into the other so a client can use a class it otherwise couldn't. Facade solves a complexity problem: the underlying subsystem's interface is already perfectly usable, it's just made up of several classes and calls that need to happen in a specific order to accomplish one task. A facade doesn't translate anything -- it coordinates. Mixing the two up in practice usually shows up as reaching for an adapter to hide multi-step complexity, which doesn't actually simplify anything since the adapter still has to expose every step, or reaching for a facade to fix a genuine interface mismatch, which doesn't compile because the facade's method signature still doesn't match what the client needs.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response