I am here to continue the discussion around design patterns. Today, we will go through one of the structural design patterns called Facade.
Before talking about its implementation, let’s begin by defining it.
As per GOF guys, Facade pattern is defined as:
“Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.”
All right! Let’s understand what they mean.
It means that when you have several sub-systems or classes, it’s often difficult for a client to interact with all of them, and if somehow the client manages to interact, the code becomes messy and difficult to maintain for any future change.
How Façade pattern works
Facade addresses the same problem by having just one interface (or wrapper class) to interact with client for all of its need. The wrapper class, internally handles all the complexity of interactions with other sub-systems.
Let’s understand this by a simple example.
We will take the same car example to illustrate the concept.
Let’s begin with building the sub-systems classes as in the following:
- class Body
- {
- public void AssembleBody()
- {
- Console.WriteLine("Assembling Body...");
- }
- }
- class Engine
- {
- public void AssembleEngine()
- {
- Console.WriteLine("Assembling Engine...");
- }
- }
- class Tyre
- {
- public void AssembleTyre()
- {
- Console.WriteLine("Assembling Tyre...");
- }
- }
- class Accessories
- {
- public void AssembleSeat()
- {
- Console.WriteLine("Assembling Seat...");
- }
- public void AssembleMusicSystem()
- {
- Console.WriteLine("Assembling Music System...");
- }
- }
So, the sub-system is built now. Now, let’s design our Facade class which will talk to the client by some public methods exposed by it.
- class CarFacade
- {
- Body body;
- Engine engine;
- Tyre tyre;
- Accessories accessories;
- public CarFacade()
- {
- body = new Body();
- engine = new Engine();
- tyre = new Tyre();
- accessories = new Accessories();
- }
- public void AssembleCar()
- {
- Console.WriteLine("Car Assembling Started...");
- body.AssembleBody();
- engine.AssembleEngine();
- tyre.AssembleTyre();
- accessories.AssembleSeat();
- accessories.AssembleMusicSystem();
- Console.WriteLine("Car Assembling Done...");
- }
- }
Now all the required setup is ready, let’s see how client uses this.
- static void Main()
- {
- Console.Title = "Facade pattern demo";
- CarFacade carFacade = new CarFacade();
- carFacade.AssembleCar();
- }
Output
So as you can see that client only knows about a façade method called AssembleCar and is successfully able to assemble the car without going into the complexity of various sub-systems involved.
Class Diagram

Prakash TripathiPosted Apr 9, 2016, 10:42 AM
Thnx Nagaraj.
Kuppurasu NagarajPosted Apr 9, 2016, 10:37 AM
Nice article..
Prakash TripathiPosted Mar 6, 2016, 11:01 PM
Thnx Kumaresh.
Prakash TripathiPosted Mar 6, 2016, 11:00 PM
Thnx Karthiga.
Kumaresh RajalingamPosted Mar 6, 2016, 8:29 PM
good one
Kumaresh RajalingamPosted Mar 6, 2016, 8:29 PM
Nice explanation
Sr KarthigaPosted Mar 6, 2016, 8:18 PM
good one
Sr KarthigaPosted Mar 6, 2016, 8:18 PM
Nice explanation
Prakash TripathiPosted Jan 27, 2016, 8:34 PM
Thnx sthitaprajnya.
Prakash TripathiPosted Jan 27, 2016, 8:33 PM
Thnx Santhakumar.
Sthitaprajnya Debasis NayakPosted Jan 27, 2016, 3:40 PM
Very Much Helpful Article !!!
Santhakumar MunuswamyPosted Jan 27, 2016, 1:57 PM
Thanks for nice share
Prakash TripathiPosted Jan 27, 2016, 10:01 AM
@Maruthi, feel free to get back to me if u have any specific question.
Prakash TripathiPosted Jan 27, 2016, 7:04 AM
Thnx Ankit.
Ankit BansalPosted Jan 27, 2016, 6:15 AM
Nice share..thanks..
Prakash TripathiPosted Jan 27, 2016, 6:08 AM
Thnx Humayun.
Prakash TripathiPosted Jan 27, 2016, 6:08 AM
Thnx Aqib.
Humayun Kabir MamunPosted Jan 27, 2016, 5:26 AM
Nice...
Muhammad Aqib ShehzadPosted Jan 27, 2016, 5:24 AM
fabulous article
Prakash TripathiPosted Jan 27, 2016, 3:45 AM
@Maruthi, Basically it's simplify the interactions between client and business logic by exposing concrete methods. It's useful when there are several sub-systems involved. In the absence of this pattern client had to make lot of interactions which is not just costly but also messy. Hope this clarifies.
Prakash TripathiPosted Jan 27, 2016, 3:31 AM
Thnx Ibrahim.
Mohammed IbrahimPosted Jan 27, 2016, 3:23 AM
nice
Maruthi PalllamalliPosted Jan 27, 2016, 3:08 AM
I am so much interested on design patterns. We can solve so many problems by using Design Patterns. So what kind of problems we can solve with Facade design pattern ?