Aug 232011
 

You have probably heard of Session Façade when you join some class or course for Enterprise JavaBean (EJB). But can you tell how to implement the Façade Pattern? In this post I will help you.

What is Façade Pattern?

The Session Façade implements exactly the idea of Façade Pattern. Let’s see how the EJB-specs describes the Session Façade by giving us this picture:

facade design pattern session facade thumb Façade Design Pattern Tutorial

As you can see, the above picture now can give you a first look at the definition of Façade: It’s the way of wrapping and hiding the complicated details from the client. Instead it give the client a simpler interface to do the job.

And for the formal one, we can say that: Façade is a Structural Design Pattern to provide a simplified interface to a group of subsystems or a complex subsystem.

Façade Pattern Example:

Let’s give an example by watching how a computer boot-upfacade pattern computer boot thumb Façade Design Pattern Tutorial

A computer is combined of so many parts/devices like: the CPU, the memory (RAM/ROM), the storage unit (HDD,CD,USB Flash)…and many others.

The process of booting a computer is as follow: CPU, Memory and Hard Drive are turn on() and then the CPU freeze() to wait for instructions to load() in to memory. CPU will then execute() command by command to startup the OS.

That’s for the story. Now as always, I will demo the above story with some Java source code:

Continue reading »