Click here to Skip to main content
14,601,782 members

Façade Design Pattern

Rate this:
0.00 (No votes)
Please Sign up or sign in to vote.
0.00 (No votes)
24 Sep 2014CPOL
Façade design pattern

What Does Façade Mean ??

A facade or façade is generally one exterior side of a building, usually, but not always, the front. The word comes from the French language, literally meaning “frontage” or “face”.

GOF –> Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.


  1. Facade: Knows which subsystem classes are responsible for a request. Delegates client requests to appropriate subsystem objects.
  2. Subsystem classes: Implements subsystem functionality. Handle work assigned by Facade object. Have no knowledge of the facade; that is, they keep no references to it.

Let us look at a simple representation of this pattern.


Now that we have understood what a Facade actually is and what GOF have interpreted with this, we will go ahead and look at a very simple and real world application of this pattern.

This is an abstract example of how a client (“you”) interacts with a facade (the “computer”) to a complex system (internal computer parts, like CPU and HardDrive).

The operations are somewhat as given below:

  1. Processor is first frozen.
  2. Memory is then loaded with the help of Hardrive information.
  3. Processor then jumps to the location returned by the memory.
  4. Processor then executes from that particular location.

First, we will see with the Facade pattern how the code looks like:

class CPU {
    public void freeze() { ... }
    public void jump(long position) { ... }
    public void execute() { ... }
class Memory {
    public void load(long position, byte[] data) { ... }
class HardDrive {
    public byte[] read(long lba, int size) { ... }

The above classes, viz. CPU, Memory and HardDrive form the SUB-SYSTEMS.
Now if we were to write a client to call these methods, it would look something like below:

class Client {
public static void main(String[] args) {
        CPU mycpu = new CPU();
    Memory mymemory = new Memory();
    HardDrive hd = new HardDrive();

    mymemory.load(BOOT_ADDRESS,,     SECTOR_SIZE));

So from the above code:

  1. The client knows about the subsystem implementation which is incorrect.
  2. There is a strong coupling between Client and the subsystem which is incorrect.
  3. There is no generality to the code, thus you need to keep disturbing client code even if the subsystem code changes.

Thus to avoid all the above problems, we will implement the same using a Facade design pattern.

Again, we will look at the subsystem which will remain the same.

/* Complex parts */
class CPU {
    public void freeze() { ... }
    public void jump(long position) { ... }
    public void execute() { ... }
class Memory {
    public void load(long position, byte[] data) { ... }
class HardDrive {
    public byte[] read(long lba, int size) { ... }

Now we will look at the Facade object participant which comes into the picture.

/* Facade */
class ComputerFacade {
    private CPU processor;
    private Memory ram;
    private HardDrive hd;
    public ComputerFacade() {
        this.processor = new CPU();
        this.ram = new Memory();
        this.hd = new HardDrive();
    public void start() {
        ram.load(BOOT_ADDRESS,, SECTOR_SIZE));

Thus, we have clean implementation and a single object of this class will solve all our problems. Thus this class abstracts the subsystems.

Now we will look at the client.

class You {
    public static void main(String[] args) {
        ComputerFacade computer = new ComputerFacade();


  1. Provide simple interface to complex subsystems
  2. When there are many dependencies between clients and implementation class
  3. You want to neatly layer your subsystem

Image 2 Image 3 Image 4 Image 5 Image 6 Image 7 Image 8 Image 9


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
India India
Passionate about Microsoft Technologies like WPF, Windows Azure, ASP.NET, Win Phone and also on Cross platform Mobile Apps, Mongo DB's, IOT & WOT. I love learning and working with (or) Creating Design Patterns . Writer | Technology Evangelist | Technology Lover | Microsoft Developer Guidance Advisory Council Member | Cisco Champion | Speaker |

Blog :

Comments and Discussions

-- There are no messages in this forum --
Technical Blog
Posted 24 Sep 2014

Tagged as


1 bookmarked