Chapter 3. Presentation Tier Architecture
All applications eventually evolve into
operating systems.
We begin our discussion of enterprise applications with the
presentation tier and a single question:
how can we manage the evolution of our software?
There's no simple answer. To successfully maintain
software over the long term, we must create an architecture that
allows the programmer to extend and rearrange the underlying
components. The architecture needs to balance flexibility,
extensibility, and performance.
In J2EE, the server-side presentation tier is
responsible for most of an application's complexity.
Since the presentation tier controls the user experience (and, by extension,
the bulk of an application's feature set),
it's often a magnet for change requests. The
servlets, HTML, JSP pages, and other resources that make up the
presentation tier tend to evolve like most pieces of complex
software. User requests spawn new features, and new features create
new code.
Since we know that software evolves, we can make our lives easier by
planning for it up front. The extensibility of
software determines how easily changes can be accommodated. Does a
word processor need to be rewritten to add an email client? What
about adding a spellchecker? An extensible program changes
gracefully: adding and updating features has minimal impact on the
rest of the program.
We sometimes know what features we'll be adding
tomorrow, next week, next revision, and next year, and so we can
create a software architecture with those directions in mind. But
much of the time this foreknowledge is unavailable梠r it turns
out to be wrong. If we're going to assume that any
application we build will be in use more than six months in the
future, we need to bake extensibility right into the underlying
architecture.
In this chapter, we look at patterns that affect the overall design
of the presentation tier with an eye toward keeping it extensible.
Here are the patterns we will discuss:
- Model-View-Controller pattern
-
Provides an architecture for the entire presentation tier that
cleanly separates state, presentation, and behavior.
- Front Controller pattern
-
Demonstrates how to centralize access in a request-based environment.
- Decorator pattern
-
Describes how to add functionality to a controller dynamically.
|