Facade Design Pattern

Facade Design Pattern

Design Patterns Serie

Intent

It hides the complexity of the system and provides an interface to the client so the client can access the system using it.

Problem

Imagine that we have a factory control unit, and the factory owner wants to control some operations, would it be rational to make him edit the code of the unit or even interact with the code? Absolutely not!
The user mostly won't have a coding background and can make things go wrong.

Solution

The facade design pattern role comes in to provide a simple interface for the user to be able to interact with a more complex system.
So, the system user (the factory owner in our case) can have a mobile app with a simple interface with on/off buttons for opening/closing valves in the factory and controlling the factory control unit.

Pros and Cons

Pros

  • You can isolate your code from the complexity of a subsystem in the same project.
  • It aids the principle of loose coupling.

Cons

  • In the case of existing code mostly it will have a complex implementation.
  • There will be a high degree of dependence on the facade interface, as the facade can become coupled to all the classes of an app.

Thank you, and goodbye.