Thursday, 1 May 2014

Facade Pattern

Classic Pattern that we come across so many times in our daily life. Facade allows us to get a service in simple and easy way. We don't need to worry or care about how the services are being provided. Here are some of the real world examples: 1) Driving a car 2) Using Mobile Phone 3) Watching TV 4) Switching On/Off electrical devices 5) Booking a flight ticket online.

There can me many more examples. There is a visible commonality across all of the above scenarios. All of them involve a simple method or way of requesting the service or activity. For example TV, we use a remote to switch on or and select a channel. We hardly care about the engineering involved.

If you think about it, when we click a button on TV remote, a wireless signal is sent to TV. It understands the signal and takes necessary action. Complex activities involving lots of engineering are triggered when we switch on TV or select a channel. But, for a user, its a simple remote that provides clear set of services.

Facade is all about providing simple and clear interfaces for services provided by the component. How the services are provided is hardly a concern for the interface user.