Facade Pattern — C#

Tiago Martins
3 min readJun 1, 2022

This is a structural pattern that provides a way to hide the complexity of the system and all its subsystems giving an interface to the client with the necessary entry points to access the main system.
When we call an elevator our interface is a simple button however, there are too many things happening in the background that are triggered due to that action.

Why is it good to use?

In a simple sentence: because it hides complexity. In a more detailed sentence: because it’s better to don’t need to know all the subsystems and how they work. How bad it would be if we need to know how to turn on all the components of a car when we start the engine? The same logic can be applied when we talk about programming. A facade gives us a well-defined interface that will allow us to interact with the entire system without knowing how many little pieces are moved when we call some method.

When should I apply it?

Once again, when you want to simplify the usage of your system by hiding numerous and complex subclasses. I believe that this is a pattern that you already have applied without knowing that was a design pattern.

Example

Let’s see an example to show how to create a good facade of a big system.

--

--

Tiago Martins

Senior Software Engineer | Cloud Native Developer | Just another programmer with some ideas.