beautypg.com

Apple WebObjects 5 User Manual

Page 28

background image

28

What Is an Enterprise Object?

Apple Computer, Inc. January 2002

C H A P T E R 3

Enterprise Objects

many applications as you need, with any user interface, and with any database
server. Therefore, you can concentrate on coding the logic of your business while
WebObjects takes care of the rest.

For example, you could create an enterprise object called Customer that defines
such business rules as customers must have a work or home phone number, or customers
cannot spend more than their credit limit
. Without rewriting your business logic, you
could use these objects in a public, Web-based application and an internal customer
service application. You could also switch the database that serves the customer
data.

Enterprise Objects and the Model-View-Controller
Paradigm

A common and useful paradigm for object-oriented applications, particularly
business applications, is Model-View-Controller (MVC). Derived from
Smalltalk-80, MVC proposes three types of objects in an application, separated by
abstract boundaries, and communicating with each other across those boundaries.

Model objects represent special knowledge and expertise. For example, model
objects can hold a company's data and define the logic that manipulates that data.
Model objects are not directly displayed. They often are reusable, distributed,
persistent, and portable to a variety of platforms.

View objects represent things visible on the user interface (for example, windows,
buttons, and so on). A view object is ignorant of the data it displays. View objects in
general are reusable, which helps in providing consistency between applications.

Acting as a mediator between model and view objects in an application is the
controller object. There is usually one per application or window. A controller object
communicates data back and forth between the model objects and view objects.
Since what a controller does is very specific to an application, it is generally not
reusable even though it often constitutes much of an application's code.

Note:

WebObjects uses the term model differently from MVC. In WebObjects, a

model establishes and maintains a correspondence between an enterprise object
class and data stored in a relational database. In MVC, model objects represent the
special knowledge of the application.