Offer one simple entry point in front of a complicated subsystem, without hiding the subsystem for those who need it.
Starting a video conversion might mean: open the file, validate the codec, allocate a decoder, configure the encoder, then run the pipeline — five classes, in the right order, with error handling at each step. Most callers just want "convert this file."
The facade exposes a small number of high-level methods. Internally it calls the subsystem's classes in the correct sequence. The subsystem classes are still there and still usable directly for anyone who needs finer control.
Callers who only need the common case use `VideoFacade.convert()`; the individual classes remain available for advanced use.
const Decoder = { open: (f) => console.log(`decoder: opened ${f}`) };
const CodecValidator = { check: (f) => console.log(`validator: codec ok for ${f}`) };
const Encoder = { configure: (fmt) => console.log(`encoder: configured for ${fmt}`) };
const Pipeline = { run: () => console.log(`pipeline: running`) };
class VideoFacade {
static convert(file, targetFormat) {
Decoder.open(file);
CodecValidator.check(file);
Encoder.configure(targetFormat);
Pipeline.run();
console.log(`done: ${file} -> ${targetFormat}`);
}
}
VideoFacade.convert("clip.mov", "mp4");