Java Reference
In-Depth Information
NOUNS Recall that an object is anything real or abstract about which you
store both attributes (data) and methods (operations) that manipulate the data.
You can think of an object as any noun. Examples of objects are an invoice, a
file, a record, a form that allows a user to interact with a program, a sales
transaction, or an employee. Parts of a graphical user interface such as menus,
buttons, and text boxes are also objects. An object may be composed of other
objects, which in turn may contain other objects. Aggregation is the term used
to describe the concept of an object being composed of other objects. An appli-
cation window, for example, can aggregate a text box, buttons, and a menu bar.
You can think of an object as a closed or black box; this is because an object
is packaged with everything it needs to work in a program. The box receives and
sends messages and contains code. A user never should need to see inside the
box because the object is self-sufficient. Programmers, however, need to know
how the object works if they are creating or maintaining code for that object, or
what the object does if writing code to send messages to the object and use it
effectively.
You have learned that a class represents an object or a set of objects that share
a common structure and a common behavior. A class also can be thought of as a
general category of object types, sometimes called an implementation, which can
be used to create multiple objects with the same attributes and behavior.
Each class may have one or more lower levels called a subclass or one or
more higher levels called a superclass . For example, a bank has many types of
accounts. A savings account is a subclass, or type, of bank account. A savings
account can be broken down further into passbook accounts and certificate
accounts. In that relationship, a savings account is a superclass of passbook and
certificate accounts. Another example might be when developing a windowed
application, programmers can use several types of toolbars. A menu bar is a
subclass of a toolbar, but it is also a superclass to a drop-down menu. The rela-
tionship among the classes, subclasses, and superclasses forms a hierarchy. A
generalization hierarchy is an object-oriented design tool used to show the
relationships among classes (Figure 1-19).
Bank
Customers
Mortgage
Customers
Savings
Customers
Checking
Customers
Passbook
Customers
Certificate
Customers
FIGURE 1-19
 
Search WWH ::




Custom Search