OOP Structural Patterns: Facade

Dated Oct 3, 2026; last modified on Sat, 03 Oct 2026

Definition

A facade is an orchestrator class that hides the complexity of coordinating multiple components behind a clean interface. It’s rare to explicitly name it as most new code design clean orchestrators from scratch. You might name it when wrapping existing messy code, e.g., after inheriting a complex subsystem with awkward APIs.

Sample Code

public enum GameState { InProgress, Won, Draw }

public class Board
{
  public bool PlaceMark(int r, int c, string mark) { ... }
  public bool CheckWin(int r, int c) { ... }
  public bool IsFull() { ... }
}

public class Player
{
  public string Mark { get; }
  public Player(string mark) { ... }
}

public class Game // This is the Facade
{
  private readonly Board _board;
  private readonly Player _playerX;
  private readonly Player _playerO;
  private Player _currentPlayer;
  private GameState _gameState;

  public Game() { ... }

  public bool MakeMove(int r, int c)
  {
    if (_gameState != GameState.InProgress) return false;

    if (!_board.PlaceMark(r, c, _currentPlayer.Mark)) return false;

    if (_board.CheckWin(r, c))
      _gameState = GameState.Won;
    else if (_board.IsFull())
      _gameState = GameState.Draw;
    else
      _currentPlayer = _currentPlayer == playerX ? playerO : playerX;

    return true;
  }
}

References

  1. Design Patterns | Hello Interview Low Level Design. www.hellointerview.com . Accessed Oct 3, 2026.