• Indicate a package by placing the name of the package in a rectangle left-aligned with
a larger box that may show classes and interfaces. Figure C.1 shows a portion of the
• UML does not require that a diagram show everything about a portrayed element, such
as the complete contents of a package or all the methods of a class.
• Draw a class by placing the name of a class centered in a rectangle. Figure C.1 shows
two classes: Classification and Firework .
• You can show a class's instance variables in a rectangle beneath the class name. The
Firework class has instance variables name , price , and classification .
Follow the variable's name by a colon and the variable's type.
• You can show a class's methods in a second rectangle beneath the class name. The
Firework class has a constructor, a method with the same name as the class. The
class also has at least three other methods: flies() , getName() , and
• When a method accepts parameters, you should usually show them, as the
setClassification() method does.
• Variables in method signatures usually appear as the name of the variable, a colon,
and the type of the variable. You may omit or abbreviate the variable name if its type
implies the variable's role.
• You may indicate that an instance variable or a method is protected by preceding it
with a pound sign ( # ). A plus sign ( + ) indicates that a variable or a method is public,
and a minus sign ( - ) indicates that a variable or a method is private.
• Indicate that an instance variable is static—and thus has class scope—by underlining
it, as the flies() method shows.
• Make notes by drawing a dog-eared rectangle. The text in notes may contain
comments, constraints, or code. Use a dashed line to attach notes to other diagram
elements. Notes can appear in any UML diagram, although this topic uses notes only
in class diagrams.
Figure C.2 shows a few of UML's features for modeling class relationships. Following are
notes on class relationship notation.