An object-oriented program
is build from several classes. Each class
defines a type of object and the program works
through the interactions of these objects. Objects interact
by invoking methods. A method defines an
action that an object can carry out. It may be as simple
as reporting a data value or it may be a complex computation
that changes the state of that object. Objects know about
other objects defined by different classes and can invoke their
methods. In this way complex interactions that comprise
the execution of the program take place.
Where do all these classes come from? How are the objects
created and stated? Often we use classes that are part
of the standard Java library or are part of another special
purpose library. We also define our own classes.
We define objects using these classes. We will use a library
called
objectdraw , developed at Williams College.
The objectdraw library provides graphical objects and objects
that can "sense" mouse actions from the system.
A program always has one class that acts as a driver
or initiator of actions. This special class is responsible
for creating enough objects defined by other classes to get
the program started. Once the first few objects are created,
their interactions drive the program. The driver class
may or may not have a significant role, once the program is
under way; this depends on the design.
There are two types of driver
in Java, an application and an applet.
In addition, there are two common types of program. A stand-alone
program carries out its function independently, once
the application or applet has started. An interactive
or event-driven program sets up the initial configuration,
then reacts to events from outside the program, such as mouse
clicks or keystrokes by the user, or events from sensors.
Back
Home
Next:
A diagram of these alternatives.