Java Reference
In-Depth Information
Class Diagram
A class diagram depicts the static relationships that exist among a group of classes and
interfaces in the system. The different types of relationships that I will discuss are gener-
alization, aggregation, and inheritance. Figure 1-8 shows the UML notation for a class
used to represent the details of an insurance claim. It is represented by a rectangle with
three compartments. The first compartment is the name of the class. The second com-
partment denotes the attributes in the class, and the last one shows the operations
defined on these attributes. Note that the + and - signs before the attribute and method
names are used to represent the visibility. The + sign denotes public visibility, and the -
sign denotes private visibility or that the attribute is not accessible outside this class. Also
note that, optionally, you can denote the data type of the attributes, method return type,
and parameters.
Figure 1-8. UML class notation
Interfaces lay down the contract that implementations must fulfill. In other words,
classes that implement an interface provide a guaranteed set of behavior. An interface is
represented by the same rectangular box as a class, but with a difference. The top com-
partment shows the class name augmented by a stereotype <<interface>>. Stereotypes
are a mechanism to extend an existing notation. Some UML tools also represent inter-
faces with a circle with no explicit mention of the methods. Figure 1-9 shows the two
different forms.
Figure 1-9. UML interface notations
Search WWH ::

Custom Search