Chapter 7. Application and system design guidelines 141
7.2 Application structure
A Self-Service Web application can be viewed as a set of interactions between
the browser and the Web application server. The interaction usually begins with
an initial request by the browser for the welcome page of the application. This is
most often done by the user typing in the welcome page URL on the browser. All
subsequent interactions are initiated by the user by clicking a button or a link.
This causes a request to be sent to the Web application server. The Web
application server processes the request and dynamically generates a results
page and sends it back to the client along with a set of buttons and links for the
next request.
A closer examination of these interactions reveals a common set of processing
requirements that need to be considered on the server side. These interactions
can be easily mapped to the classical Model-View-Controller design pattern. As
outlined in the book Design Patterns: Elements of Reusable Object-Oriented
Software, the relationship between the MVC triad classes are composed of
Observer, Composite, and Strategy design patterns.
We start this section with a detailed look at the MVC design pattern. After that,
we examine some design patterns for interaction between MVC components and
some implementation considerations for the MVC components, including:
򐂰 Result bean design pattern
򐂰 View bean design pattern
򐂰 Formatter beans design pattern
򐂰 Command bean design pattern
򐂰 Frameworks including Struts and EAD4J
򐂰 WebSphere command framework with EJBs
򐂰 Best practices for EJBs
7.2.1 Model-View-Controller design pattern
Over the years, a number of GUI-based client/server applications have been
designed using the Model-View-Controller (MVC) design pattern. This powerful
and well-tested design pattern can be extended to support Self-Service Web
applications.
This section will describe the MVC pattern in detail. Note that in practice, we
expect that an existing MVC based design framework, such as JSF or Struts will
be used. However, in order to provide a broader view of the key design issues,
this section will not focus on any one framework. The frameworks described in a
later section.
As shown in Figure 7-1 on page 142,
Model represents the application object
that implements the application data and business logic. The
View is responsible
142 Patterns: Implementing Self-Service in an SOA Environment
for formatting the application results and dynamic page construction. The
Controller is responsible for receiving the client request, invoking the appropriate
business logic, and based on the results, selecting the appropriate view to be
presented to the user.
Figure 7-1 The Model-View-Controller design pattern
A number of different types of skills and tools are required to implement various
parts of a Web application. For example, the skills and tools required to design
an HTML page are vastly different from the skills and tools required to design
and develop the business logic part of the application. In order to leverage these
scarce resources effectively and to promote reuse, we recommend structuring
Web applications to follow the Model-View-Controller design pattern.
Throughout this chapter,
Model is often referred to as business logic, View is
referred to as page constructor or display page, and
Controller is referred to as
interaction controller. This section further outlines the responsibilities of each of
these components and discusses what technologies could be used to implement
the same.
Interaction controller (Controller)
The easiest way to think about the responsibility of the interaction controller is
that it is the piece of code that ties protocol-independent business logic to a Web
application. This means that the interaction controller's primary responsibility is
mapping HTTP protocol-specific input into the input required by the
Browser Client
Web Application Server
Business Logic
Model
Page
Construction
View
Controller
Interaction
Controller

Get Patterns: Implementing Self-Service in an SOA Environment 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.