Facade Pattern
Offer a simple entry point to several subsystem operations without absorbing all their business rules.
· Last updated: 2026-11-05 · 7 min read
Overview
Playing a movie means lowering the screen, dimming the lights and starting the player. Repeating those steps in each screen's button handler duplicates the preparation code; changing a device or the order then means updating every screen.
A facade offers this preparation through one method. The screen asks to start a movie, and the facade calls the required devices in order, giving callers a simple entry point to a complex subsystem.
UML
Here the entry point takes shape as a single class. The only object the caller meets directly is MovieNight. MovieNight references Screen, Lights and Player, and makes those calls on the caller's behalf in the order that starting and stopping require.
History
GoF cataloged Facade as a structural pattern in Design Patterns in 1994. It offers a higher-level interface that makes a subsystem easier to use.1
Why use it?
Nothing is left to copy into the screens. Callers do not need to know either the name of each device or the preparation order. When that order changes, the fix belongs in this one entry point rather than in every screen.
A facade is an entry point, not a dumping ground. What it takes away is the calling sequence; the judgment stays where it was. If it takes on every business rule, or bundles even callers that need fine-grained control into one method, all that is left is one large object, so responsibility for the lower-level pieces stays with the module that owns them.
Example
The code makes the split visible. The process of starting a movie is bundled into a single method. The devices in the example return the name of the action they would perform instead of touching real hardware.
using System;
using System.Collections.Generic;
using System.Linq;
var night = new MovieNight(new Screen(), new Lights(), new Player());
Console.WriteLine(night.Start("Moon"));
// Separate an individual device operation from multi-device coordination.
sealed class Screen
{
public string Lower() => "screen down";
public string Raise() => "screen up";
}
sealed class Lights
{
public string Dim() => "lights dim";
public string Restore() => "lights normal";
}
sealed class Player
{
public string Play(string title) => "play " + title;
public string Stop() => "player stop";
}
// Keep the preparation sequence here rather than in every caller.
sealed class MovieNight(Screen screen, Lights lights, Player player)
{
public string Start(string title) =>
string.Join(" -> ", screen.Lower(), lights.Dim(), player.Play(title));
public string Stop() =>
string.Join(" -> ", player.Stop(), lights.Restore(), screen.Raise());
}
screen down -> lights dim -> play MoonEach device object handles its device, while MovieNight's Start() decides the order in which to call those objects. The output follows the order written in Start().
An extended example
The example widens its scope. The matching stop operation lives on the same facade, so the start call flows straight into the stop call.
using System;
using System.Collections.Generic;
using System.Linq;
var night = new MovieNight(new Screen(), new Lights(), new Player());
Console.WriteLine(night.Start("Moon"));
Console.WriteLine(night.Stop());
// Separate an individual device operation from multi-device coordination.
sealed class Screen
{
public string Lower() => "screen down";
public string Raise() => "screen up";
}
sealed class Lights
{
public string Dim() => "lights dim";
public string Restore() => "lights normal";
}
sealed class Player
{
public string Play(string title) => "play " + title;
public string Stop() => "player stop";
}
// Keep the preparation sequence here rather than in every caller.
sealed class MovieNight(Screen screen, Lights lights, Player player)
{
public string Start(string title) =>
string.Join(" -> ", screen.Lower(), lights.Dim(), player.Play(title));
public string Stop() =>
string.Join(" -> ", player.Stop(), lights.Restore(), screen.Raise());
}
screen down -> lights dim -> play Moon
player stop -> lights normal -> screen upPutting the calls in one method does not guarantee that every device operation succeeds. With real devices, you still need to decide how to report a failure midway through and how to recover devices that have already acted. The Query Facade article covers using a facade to assemble query results.
TypeScript example
Port the same shape to TypeScript and the split lands in the same place. Devices handle their own operations, while MovieNight takes care of the call sequence needed to start and finish a movie. No one has to copy the preparation order into every screen, and the details of each device stay with the object they belong to.
// Separate an individual device operation from multi-device coordination.
class Screen {
lower(): string { return "screen down"; }
raise(): string { return "screen up"; }
}
class Lights {
dim(): string { return "lights dim"; }
restore(): string { return "lights normal"; }
}
class Player {
play(title: string): string { return "play " + title; }
stop(): string { return "player stop"; }
}
// Keep the preparation sequence here rather than in every caller.
class MovieNight {
constructor(private readonly screen: Screen, private readonly lights: Lights, private readonly player: Player) {}
start(title: string): string {
return [this.screen.lower(), this.lights.dim(), this.player.play(title)].join(" -> ");
}
stop(): string {
return [this.player.stop(), this.lights.restore(), this.screen.raise()].join(" -> ");
}
}
const night = new MovieNight(new Screen(), new Lights(), new Player());
console.log(night.start("Moon"));
console.log(night.stop());screen down -> lights dim -> play Moon
player stop -> lights normal -> screen upThe returned strings are only stand-ins for showing the order of operations, and they guarantee neither control of the real devices nor that several operations succeed atomically.
Related reading
Footnotes
- Gamma, Helm, Johnson, Vlissides. Design Patterns (1994). Publisher record. Structural patterns, Facade. ↩