Facade Pattern
2022-03-12
0. What is Facade Pattern?
Used to solve 2 problems:
- Big Ball of Mud: a class is using a big class’s methods
- Multiple workers: a class needs to call multiple services to complete a task
1. Implementation of Facade Pattern
Components & Steps
- Define a Facade Interface
- Add a facade interface implementation class to handle all the logics
- 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);