The Facade Pattern provides a simplified interface to a complex body of code, such as a class library. It doesn't hide the complex subsystem entirely; it just provides a "Shortcut" for the most common tasks, saving developers from having to learn 50 different classes just to do one simple thing.
Imagine a subsystem with 20 classes: AudioLayer, VideoSync, BitrateManager, Encoder, etc. You just want to convert a file. The Facade provides a single ConvertMethod().
public class VideoConverterFacade
{
public void Convert(string filename, string format)
{
var file = new VideoFile(filename);
var sourceCodec = new CodecFactory().Extract(file);
// ... calls 10 more internal classes ...
var result = new VideoEncoder().Encode(file, format);
}
}
It improves **Maintainability**. If the internal library changes (e.g., you upgrade your video engine), you only have to fix the code inside the Facade. The 50 other developers using your system don't have to change a single line of their code.
Q: "What is the difference between an Adapter and a Facade?"
Architect Answer: "The difference is one of **Scope**. An **Adapter** wraps *one* object to make its interface compatible with another. A **Facade** wraps an *entire subsystem* of many objects to provide a simpler entry point. Adapter makes two things work together; Facade makes a complex thing easy to use."