Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
This page is a work in progress
We roll out the updates weekly. Leave your email to track the progress. You can expect one email per month and no spam, pinky promise.
Structure of design pattern
// Some classes of a complex 3rd-party video conversion framework. We don't // control that code, therefore can't simplify it. class VideoFile // ... class OggCompressionCodec // ... class MPEG4CompressionCodec // ... class CodecFactory // ... class BitrateReader // ... class AudioMixer // ... // To defeat the complexity, we create a Facade class, which hides all of the // framework's complexity behind a simple interface. It is a trade-off between // functionality and simplicity. class VideoConvertor is method convertVideo(filename, format):File is file = new VideoFile(filename) sourceCodec = new CodecFactory.extract(file) if (format == "mp4") distinationCodec = new MPEG4CompressionCodec() else distinationCodec = new OggCompressionCodec() buffer = BitrateReader.read(filename, sourceCodec); result = BitrateReader.convert(buffer, distinationCodec); result = (new AudioMixer()).fix(result); return new File(result) // Application classes don't depend on a billion classes provided by the complex // framework. Also, if you happen to decide to switch framework, you will only // need to rewrite the facade class. class Application is method main() is convertor = new VideoConvertor(); mp4video = convertor.convertVideo("youtubevideo.ogg", "mp4")