UML Class Diagrams: A Summary of the Basics
Home > SoftwareDesign > UML
Basic shapes and symbols of UML 2.x class diagrams

Figure 1: Basic shapes and symbols
of UML class diagrams
- A class is drawn as a rectangle. The name of the class is
displayed in bold type, inside the rectangle, and aligned
centrally. When no other details of the class are shown the name
may be displayed in the middle of the rectangle. In all other
circumstances the name is displayed at the top of the rectangle. If the
class is declared as abstract, the name of the class is drawn in
italics.
- The name of one or more stereotypes may be displayed above the
name of the class as a comma-separated list within a pair of guillemot
characters.
- Below the name of the class, the rectangle may be split into a
number of compartments. By default, two compartments are shown. The one
immediately below the name of the class lists the attributes of the
class. The second default compartment lists the operations defined for
the class.
- Each attribute of a class is identified by a name that is unique
within the set of attributes of that class. The name of an attribute is
optionally preceded by a visibility symbol (+ for public, - for
private, # for protected). The name is optionally followed by a colon
and the name of the type of the attribute. If the attribute belongs to
the class rather than to objects of the class (known as a static attribute in Java, C++, C#),
the attribute is underlined.
- Each operation of a class is shown as a name
followed by a pair of rounded brackets, and optionally preceded by a
visibility symbol (+ for public, - for
private, # for protected). Optionally, one or more parameters for the
operation may be displayed as a comma-separated list between the
rounded brackets. Each parameter is displayed as a name optionally
followed by a colon and the name of the type of the parameter. If the
operation returns a result, the type of the result may optionally be
shown after the closing round bracket but must be preceded by a colon
character. If the operation is defined for
the class rather than objects of the class (known as a static attribute in Java, C++, C#),
the attribute is underlined.
- A solid line with a hollow arrow head drawn from one class to the
another represents a sub-class/super-class
(generalisation/specialisation) relationship between the two
classes. The arrow points to the super-class of the pairing.
- A solid line drawn between two classes is an association
relationship and represents links between objects of the two classes.
The association may be given an optional name, generally displayed
above or to the right of the line. Each end of the association may have
an optional multiplicity indicator showing how many of the
objects of that class are related to an object of the other class. In
addition, each end of the association may have an optional name
describing the role that objects of that class play in the relationship.
- Multiplicities either expressed as an integer or an integer range
denoted by the minimum and maximum of the range separated by two
full-stop characters (periods). An asterisk symbol may be used instead
of an integer to denote 'many'.
- Where a whole-part
relationship exists between the objects of two classes (where the
objects of one class represent parts of objects of the other class),
the relationship is drawn in the same way as an association but with an
additional diamond symbol at the whole
end of the line. If the relationship implies copy and delete control
over part objects by the whole object (if a whole object is copied or deleted,
the related part objects must
be copied or deleted at the same time), the diamond is drawn filled and
the relationship is known as composition.
Otherwise, the diamond is drawn hollow and the relationship is called aggregation.
- An interface is drawn as a rectangle in a similar way yo a class
but always has an interface stereotype label above the name of the
interface, and classes are shown as implementing an interface by
drawing a dashed line with a hollow arrowhead from the class to the
interface.
- Arbitrary notes are displayed as text within a rectangle with a fold in the top right-hand corner.
Notes are linked to their subjects by optional dashed lines without any
arrowheads.
- Other types of dependency between two classes are shown as dashed
lines drawn between the classes with a stick arrowhead pointing from
the dependent class to the class it depends upon. An optional
stereotype tag, generally displayed above or to the right of the dashed
line, shows the kind of dependency (e.g. uses, instantiates, etc) being
modeled.