How does the Façade pattern help reduce coupling between modules?
The Facade pattern reduces coupling between modules because it introduces a single point of interaction between a subsystem and external code, isolating them from each other.
1. It Hides the Internal Structure
The client communicates only with the facade, without knowing which classes and dependencies exist inside. If something inside the module changes (class names, structure, method signatures), the client code does not suffer, because the facade's interface stays the same.
2. It Minimizes the Number of Dependencies
Without a facade, the client depends on dozens of classes in the module. With a facade, it depends on just one:
// without a facade
Codec codec = new MPEG4Codec();
AudioMixer mixer = new AudioMixer();
BitrateReader.read(file, codec);
mixer.fix(file);
// with a facade
VideoConverter.convert("movie.avi", "mp4");This makes the system more isolated and resistant to change.
3. It Separates Responsibility Between Layers
The facade creates clear boundaries between modules:
- the subsystem decides "how to do it",
- the facade decides "what is exposed outward". This way, the layers of the application do not "leak" into each other.
4. It Simplifies Maintenance and Testing
If the client depends only on the facade, the subsystem can be tested in isolation, without complex ties to other modules.
5. Conclusion
The facade reduces coupling through:
- encapsulating internal logic,
- limiting access points,
- reducing the number of dependencies between components.
Summary: The client sees a simple API and does not depend on implementation details, while the system inside can change without the risk of "breaking" external code.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.