Facade
Facade
Section titled “Facade”One-line pattern summary
Section titled “One-line pattern summary”A pattern that wraps a complex subsystem with a simple top-level API to improve usability.
Typical Unity use cases
Section titled “Typical Unity use cases”- When hiding a game boot sequence behind one method.
- When internal module details should be hidden from the outside.
Parts (roles)
Section titled “Parts (roles)”- Facade
- Subsystem
- Client
Unity example (C#)
Section titled “Unity example (C#)”The code below is a simplified Unity example based on the scenario described above.
public sealed class GameStartupFacade{ private readonly SaveSystem saveSystem = new(); private readonly AudioSystem audioSystem = new(); private readonly UiSystem uiSystem = new();
public void StartGame() { saveSystem.Load(); audioSystem.Initialize(); uiSystem.OpenLobby(); }}Advantages
Section titled “Advantages”- It clarifies module boundaries and reduces coupling.
- Features can be extended or integrated without modifying existing code.
Things to watch out for
Section titled “Things to watch out for”- If wrapper layers become too deep, debugging gets harder.
- Interfaces should stay small so responsibility boundaries do not blur.
Interaction diagram
Section titled “Interaction diagram”This shows the flow where complex subsystem calls are simplified into a single entry point.