beautypg.com

Separation of presentation, logic, and data, State management – Apple WebObjects 5 User Manual

Page 21

background image

C H A P T E R 2

What Is WebObjects?

The WebObjects Advantage

21

Apple Computer, Inc. January 2002

mechanism for cleanly instantiating business objects directly from database tables.
WebObjects handles all the interactions with the database including fetching,
caching, and saving. This allows you to write your business logic against actual
objects independent of the underlying datasource. You can modify schemas, add or
change databases, or even use totally a different storage mechanism without
needing to rewrite your application.

WebObjects applications can access any database with a JDBC 2.0 driver. JDBC is an
interface between Java platforms and databases.

Separation of Presentation, Logic, and Data

An ideal Web application development system simplifies maintenance and
encourages code reuse by enforcing a clean separation of presentation (HTML),
logic (Java), and data (SQL). This modularity is inherent in the WebObjects
programming model, which uses reusable components to generate Web pages
directly from enterprise objects without the need to embed scripts or Java code
inside your HTML. A component contains a template, which you—or a professional
Web designer—can lay out and edit using standard Web authoring tools. A
component can also implement custom behavior using a separate Java source file.
Neither the template nor the Java source file includes model-specific information.

State Management

The HTTP protocol used on the Web is inherently stateless; that is, each HTTP
request arrives independently of earlier requests, and it is up to Web applications
to recognize which ones come from an individual user or session. Therefore, most
Web applications of consequence—as well as some of the more interesting dynamic
publishing sites—need to keep state information, such as login information or a
shopping basket, associated with each user session.

Without using cookies, WebObjects provides objects that allow you to maintain
information for the life of a particular client session, or longer. This makes it
particularly easy to implement an application like a Web-based online store: you
don’t have to do anything special to maintain the contents of the user’s shopping
cart or other data over the life of the session. In addition, your online store could
even monitor individual customer buying patterns and then highlight items they’re
more likely to be interested in the next time they visit your site.