Simplifying interfaces – Apple WebObjects 3.5 User Manual
Page 96

Chapter 6
Creating Reusable Components
96
the World Wide Web Wisdom company could change the look of the
navigational controls in all of its applications by changing this one component.
If your application’s pages are highly structured, reusable components could be
the prevailing feature of each page:
The corresponding declarations file might look like this:
HEADER: CorporateHeader {};
PRODUCTDESCRIPTION: ProductTable {productCode = "WWWW0314"};
NAVCONTROL: NavigationControl {};
FOOTER: Footer {type = "catalogFooter"};
Notice that some of these components above take arguments—that is, they are
parameterized. For example, the ProductTable component’s
productCode
attribute
is set to a particular product identifier, presumably to display a description of
that particular product. The combination of reusability and customizability is
particularly powerful, as you’ll see in the next section.
Simplifying Interfaces
Another benefit of reusable components is that they let you work at a higher
level of abstraction than would be possible by working directly with HTML
code or with WebObjects’ dynamic elements. You (or someone else) can create
a component that encapsulates a solution to a possibly complicated
programming problem, and then reuse that solution again and again without
having to be concerned with the details of its implementation. Examples of this
kind of component include:
•
A menu that posts different actions depending on the user’s choice
•
A calendar that lets a user specify start and end dates
•
A table view that displays records returned by a database query
To illustrate this feature, consider a simple reusable component, an alert panel
like the one shown in Figure 28.