by Lars Vogel

Follow me on twitter

Lars Vogel on Google+

Facade Design Pattern in Java

Lars Vogel

Version 0.1

01.07.2009

Revision History
Revision 0.1 01.07.2009 Lars
Vogel
Separated from http://www.vogella.de/articles/DesignPatterns/article.html

Facade

This article describes the Design Pattern "Facade" and its usage in the programming language Java.


Table of Contents

1. Facade
1.1. Definition
1.2. Example
1.3. Evaluation
2. Thank you
3. Questions and Discussion
4. Links and Literature

1. Facade

1.1. Definition

The Facade Pattern provides a unified interface to a set of interfaces in as subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

The Facade Pattern leaves the subsystem accessible to be used directly.

1.2. Example

Assume you have a database access class with different methods to read the different tables. The client requires the complete result. You could use a facade pattern which hides the complex database access interface behind a few easy to understand and maintainable interface, e.g. load() and get().

1.3. Evaluation

The Facade pattern simplifies the access to an complex interface but allows still the complete access to the underlying subsystem.

The Facade Pattern allows to decouple your client implementation from the subsystem.

The difference between the Adapter Pattern and the Facade Pattern is their intent. The Adapter Pattern converts one or more interfaces to an expected subsystem interface The Facade Pattern simplifies one or more interfaces to a subsystem. So an implementation point of view both are similar only distinguishable by their intent.

2. Thank you

Thank you for practicing with this tutorial.

3. Questions and Discussion

Before posting questions, please see the vogella FAQ. If you have questions or find an error in this article please use the www.vogella.de Google Group. I have created a short list how to create good questions which might also help you.

4. Links and Literature

http://en.wikipedia.org/wiki/Design_Patterns Wikipedia Entry about the GOF Design Pattern book.