Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
I had been working at Sun Microsystems for just over a year when the mandate came from on high to switch to Java. In those days, you could become a Java expert in a scant few months, and we did, rewriting an existing C++ application in Java. Today, of course, it's a different story—novice Java developers must learn a huge API, including the basics such as collections, JavaBeans, input/output (I/O), Swing, internationalization and localization, and more, not to mention ancillary topics like Ant, Java API for XML Parsing (JAXP), log4j, JavaServer Pages (JSP), JSP Standard Tag Library (JSTL), JavaServer Faces, Java Message Service (JMS), Enterprise JavaBeans (EJB), Java Data Objects (JDO), AspectJ...the list goes on and on. Just keeping up with the onslaught of new technologies is more than a full-time job.
Object-oriented development helps manage complexity by encapsulating data and functionality in classes with well-defined interfaces, and Java lets you encapsulate classes in packages. But that encapsulation only goes so far; sometimes you have to delve into complex APIs to do even the simplest things, as EJB developers can attest.
Although object-oriented development fails to reduce the complexity of learning a new API, we can use its facilities to implement a design pattern that does: the Façade pattern, where objects known as façades offer a simple interface to complex subsystems so you can do something without knowing the subsystem's particulars. Let's see how the Façade pattern works.
Note: You can download the associated source code from Resources.
In Design Patterns, the authors describe the Façade pattern like this:
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.
Figure 1 shows the Façade design pattern's class diagram.

Figure 1. Façade class diagram
Java consists of high-powered APIs that let you do everything from developing killer graphical user interfaces (GUIs) to sending asynchronous messages between distributed objects. But those high-powered APIs can make it incredibly difficult to do the simplest things; for example, consider the "simple" GUI application that I discuss in "A Swing Application Façade" below.
The Façade pattern is easy to understand: one class provides a simplified interface to a subsystem. Façades make the easy stuff easy; for the hard stuff, you must delve into the subsystem itself. But façades typically accommodate a high percentage of a subsystem's use cases and, therefore, they are particularly valuable; so valuable in fact, that as we shall see in the "JOptionPane: Swing's Façade for Dialogs" section below, complex subsystems such as Swing's API for windows and dialog boxes often implement façades of their own that simplify their use.
This installment of Java Design Patterns examines two uses of the Façade pattern. The first discusses a built-in Swing façade that simplifies the use of dialog boxes, and the second examines a custom façade implementation that makes it easy to throw together a Swing application.