Facade Design Pattern

Divesh Singh
2 min readNov 6, 2019

So, As the name suggests, it means the face of the building. The people walking past the road can only see this glass face of the building. They do not know anything about it, the wiring, the pipes, and other complexities. It hides all the complexities of the building and displays a friendly face.

Now Let’s try to understand the facade pattern better using a simple example.

Let’s consider a hotel. This hotel has a hotel keeper. There are a lot of restaurants inside the hotel e.g. Veg restaurants, Non-Veg restaurants, and Veg/Non Both restaurants.
You, as a client want access to different menus of different restaurants. You do not know what are the different menus they have. You just have access to a hotel waiter who knows his hotel well. Whichever menu you want, you tell the hotel waiter, and he takes it out of from the respective restaurants and hands it over to you. Here, the hotel waiter acts as the facade, as he hides the complexities of the system hotel.

Another example: When you’re using online shopping, you look for some outward indication that the website you’re on has a virtual storefront. It provides what types of services are available.

As parts of your system become larger, they naturally become more complex.

This can be potentially confusing for the client classes in your system to use.

The scope of the problem you’re trying to solve may be so large, it requires a complex solution.

Client classes, however, would prefer a simpler interaction. The facade design pattern provides a single simplified interface for client classes to interact with the subsystem.

What is a facade?

If you’ve ever gone shopping at a retail store or ordered anything online, you’ve had experience interacting with the real world facade design pattern. Picture yourself walking down the street looking for a place to have dinner.

Keep in mind that a facade does not actually add more functionality, a facade simply acts as a point of entry into your subsystem.

In software, the facade design pattern does exactly what a waiter or salesperson would do in real life.

A facade is a wrapper class that encapsulates the subsystem in order to hide the subsystem’s complexity. This wrapper class will allow a client class to interact with the subsystem through a facade.

The facade design pattern is a means to hide the complexity of a subsystem by encapsulating it behind a unifying wrapper called a facade class.

Encapsulation, information hiding, separation of concerns are the key design principles are used to implement the facade design pattern.

Facade architecture

If you find this article is helpful please do not forget to share, recommend, and clap.

--

--

Divesh Singh

Postgraduate from JEC Jabalpur || iOS and macOS developer, traveler |||| EM at Darwinbox | Ex-Samsung || Ex - Optimize IT Sys | Ex - R Systems