Benefits of reusable components – Apple WebObjects 3.5 User Manual

Page 93

Advertising
background image

93

In the simplest applications, each component corresponds to an HTML
page, and no two applications share components. However, one of the
strengths of the WebObjects architecture is its support of reusable
components: components that, once defined, can be used within multiple
applications, multiple pages of the same application, or even multiple
sections of the same page.

This chapter describes reusable components and shows you how to take
advantage of them in your applications. It begins by illustrating the benefits
of reusable components. It then describes how to design components for
reuse, how reusable components can communicate with the parent
component, and how state is synchronized between parent and child
components. Finally, it provides some design tips for you to consider when
designing your own reusable components.

Benefits of Reusable Components

Reusable components benefit you in two fundamental ways:

They help you centralize application resources.

They simplify interfaces to packages of complex, possibly
parameterized, logic and display.

The following sections explain these concepts in detail.

Centralizing Application Resources

One of the challenges of maintaining a web-based application is the sheer
number of pages that must be created and maintained. Even a modest
application can contain scores of HTML pages. Although some pages must
be crafted individually for each application, many (for example, a page that
gathers customer information) could be identical across applications. Even
pages that aren’t identical across applications can share at least some
portions (header, footer, navigation bars, and so on) with pages in other
applications. With reusable components, you can factor out a portion of a
page (or a complete page) that’s used throughout one or more applications,
define it once, and then use it wherever you want, simply by referring to it
by name. This is a simple but powerful concept, as the following example
illustrates.

Suppose you want to display a navigational control like the one shown in
Figure 27 at the bottom of each page of your application.

Advertising