Design Patterns interview question · Most asked
What is the Facade pattern?
Summary
Facade provides one simple, task-focused interface to a complex subsystem. An OrderFacade.place_order() coordinates inventory, payments, shipping and email in the right order, so callers don't repeat that sequence.
Longer Answer
The subsystem classes keep working and remain available for advanced use; the facade is a convenience, not a wall. It reduces duplication and coupling to the subsystem's details, and it is a natural boundary when layering a system.
Risk: a facade that does everything becomes a god object. Keep facades focused on one area.
Key Points
- Simple front door to a complex subsystem.
- Coordinates calls in the right order.
- Subsystem still usable directly.
- Keep it focused to avoid a god object.
Deep dive: Design Patterns, Explained Simply: Facade
Explanation
What interviewers look for
The simplification intent and the distinction from Adapter.
Follow-up questions
- Are Laravel facades GoF facades?
More most-asked Design Patterns questions
- What problem does the Builder pattern solve? Show an example.
- Explain the SOLID principles.
- What is a design pattern, and why are they useful?
- What is the difference between dependency inversion, dependency injection and inversion of control?
- Why is composition often preferred over inheritance?
- What is dependency injection, and what forms does it take?
- Explain the Factory Method pattern and how it differs from a simple factory.
- How do you implement a Singleton, and why is it often considered an anti-pattern?