Structural · DWG NO. 013

Facade

Offer one simple entry point in front of a complicated subsystem, without hiding the subsystem for those who need it.

TypeStructural
ScopeWhole subsystem
ComplexityLow
Common inSDK entry points, video encoding, boot sequences

Every caller has to learn the whole subsystem just to do one common thing

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."

One method that knows the right order

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.

VideoFacadeDecoderEncoderPipeline

One `convert()` call in front of four subsystem classes

Callers who only need the common case use `VideoFacade.convert()`; the individual classes remain available for advanced use.

video-facade.js
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");

Trade-offs