3 Façade Pattern
WHAT’S IN THIS CHAPTER?
- An introduction to the intent of the façade pattern
- A brief discussion of the benefits that the pattern brings
- Three ways that the pattern can be implemented: POJO, stateless, and stateful session bean façade
- The important differences between the stateful and the stateless session bean façade
- When and where to use this pattern
- Warnings about its use and potential pitfalls
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at www.wrox.com/go/projavaeedesignpatterns
on the Download Code tab. The code is in the Chapter 3 download and individually named according to the names throughout the chapter.
The façade pattern is one of the structural design patterns described in the GoF1 book. The intent behind it is to encapsulate complicated business logic in a higher-level interface that makes access to a subsystem easier to use. This is often done by grouping related method calls and invoking them sequentially from one method.
From a higher-level view, every API can be considered an implementation of the façade pattern since they provide a simple interface which hides its complexity. Any call to an API’s method results in the invocation of many other methods from a subsystem hidden behind it. An example of a façade would be the javax.servlet.http.HttpSession
interface. This hides the complicated logic associated with maintaining the session while exposing its functionality via a handful ...
Get Professional Java EE Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.