Java Reference
In-Depth Information
Display 12.1 A UML Class Diagram
Square
side: double
xCoordinate: double
- yCoordinate: double
+ resize( double newSide): void
+ move( double newX, double newY): void
# erase(): void
...
Class Interactions
Class diagrams by themselves are of little value, since they simply repeat the class inter-
face, possibly with ellipses. To understand a design, you need to indicate how objects
of the various classes interact. UML has various ways to indicate class interactions; for
example, various sorts of annotated arrows indicate the information flow from one
class object to another. UML also has annotations for class groupings into packages,
annotations for inheritance, and annotations for other interactions. Moreover, UML is
extensible. If what you want and need is not in UML, you can add it to UML. Of
course, this all takes place inside a prescribed framework so that different software
developers can understand each other's UML. One of the most fundamental of class
interactions is inheritance, which is discussed in the next subsection.
Inheritance Diagrams
for some classes used in a univer-
sity's record-keeping software. Note that the class diagrams are incomplete. You nor-
mally show only as much of the class diagram as you need for the design task at hand.
Note that the arrow heads point up from a derived class to its base class.
The arrows also help in locating method definitions. If you are looking for a
method definition for some class, the arrows show the path you (or the computer)
should follow. If you are looking for the definition of a method used by an object of
the class
Display 12.2 shows a possible
inheritance diagram
inheritance
diagram
arrows
, you first look in the definition of the class
; if
Undergraduate
Undergraduate
it is not there, you look in the definition of
; if it is not there, you look in the
Student
definition of the class
.
Display 12.3 shows some possible additional details of the inheritance hierarchy
for the two classes
Person
and one of its derived classes,
. Suppose
is an
Person
Student
s
 
Search WWH ::




Custom Search