Luna Tech

Tutorials For Dummies.

Facade Pattern

2022-03-12


0. What is Facade Pattern?

Reference

Used to solve 2 problems:

  1. Big Ball of Mud: a class is using a big class’s methods
  2. Multiple workers: a class needs to call multiple services to complete a task

1. Implementation of Facade Pattern

Example Code

Components & Steps

  1. Define a Facade Interface
  2. Add a facade interface implementation class to handle all the logics
  3. Create an instantiation of the interface and call the method implemented
IServiceFacade facade = new ServiceFacade();

Tuple<int, double, string> result = facade.CallFacade();

Console.WriteLine(result.Item1 + " - " + result.Item2 + " - " + result.Item3);