CS 743 - Software Verification and Validation

Fall 2019

Informal Semantics for UML Class Diagram


This document describes informal semantics of UML 2.0 (Unified Modeling Language version 2.0) Class diagrams. The document is intended to verify UML class diagrams and not to describe how to draw a class diagram. Consequently, the readers should refer to UML manuals or books for a detailed treatment of UML notations and how to use them.

UML Class Diagram

A class diagram in UML describes the classes of the application being modeled and the relationships among these classes. It provides the structural and static view of the entire system. Depending on the level of abstraction, a class diagram may describe only those classes selected or identified in the application domain or could describe every class that will eventually be implemented. A class icon in the diagram may describe only partial information about the class; e.g., names and types of attributes and names of operations. In order to make the diagram look simple and elegant, most users provide only names of attributes and operations and include a pointer to the documentation page that contains additional details about these attributes and operations.

The relationships among the classes can be broadly classified into three categories: association, aggregation and specialization (implemented through inheritance).

Notations - Summary

An UML class diagram is composed of the following notations:

Figure 1. Various representations of class icon in a Class Diagram

 

Figure 2. Symbols representing relationships between classes in a Class Diagram

Informal Semantics

Class:  A class represents an abstraction of a collection of objects (equally treated as the type of the same collection of objects). Class is the modeling and programming entity, that is instantiated later into a set of objects at run-time. The objects instantiated from a particular class will all behave identically; these behaviors are defined by the methods (or operations) of the class. The structure of a class is defined by a set of attributes which also characterize the state of an object instantiated from the class.

A class may have an optional qualifier. If specified, the qualifier is generally one of the attributes of the class. The qualifier is used to identify a unique object/instance of the class when multiple objects/instances are used in a relationship with another class.

The name of the class must be present. The attributes and methods of the class need not be shown in the diagram. Even if they are specified, they do not need to be fully specified in the diagram. However, for verification with respect to the application domain, complete details of all attributes and methods are needed. These can be specified in a separate document outside the class diagram.

The following rules are applied to verify a class notation:

Association:  An association describes a semantic dependency between two classes. The semantics dependency can range from simple message passing to enclosing one class within another. The details of the semantic dependency may not be explicit in the diagram.

The following rules govern the use of the association symbol in a class diagram:

Aggregation:  An aggregation relationship between a pair of classes indicates that an object of one class encloses an object of the other class. The class at the diamond end of the aggregation symbol is an aggregate and the other class is a component. For example, the class "Polygon" aggregates the class "Line", in which case the diamond end of the aggregation symbol must touch the class "Polygon". An aggregation is also an association; however, there are some differences. See [1] for more details on the differences.

There are two types of aggregation - shared aggregation (represented by hallow diamond) and composition aggregation (represented by filled diamond). In shared aggregation, the component (the one at tail end of the aggregation arrow) can be shared by other aggregates. In composition aggregation, the component is not shared and is exclusively used by the aggregate to which it is connected.

The following rules govern the use of the aggregation symbol in a class diagram:

Specialization:  The specialization symbol connects a subclass (or a specialized class) to its superclass (or a generalized class). The base of the triangle should be connected to the subclass.

The following rules are applicable for the specialization symbol in a class diagram:

References:

  1. Hans-Erik Erikson et al., UML 2 Toolkit, Wiley Publishing Company, 2004, ISBN: 0-471-46361-2.
  2. Russ Miles and Kim Hamilton, Learning UML 2.0, O-Reilly, 2006, ISBN: 0-596-00982-8.
  3. Alan Dennis et al., System Analysis & Design with UML, Wiley, 2012, ISBN: 978-1118037423.
  4. Bernd Bruegge and Allen H. Dutoit, Object-Oriented Software Engineering Using UML, Patterns and Java (3rd edition), Prentice Hall, 2009, ISBN: 978-0136061250.
  5. UML Standard documents published at the Object Management Group (OMG) web site:  www.omg.org/spec/UML.
  6. James Rumbaugh et al., The Unified Modeling Language Reference Manual, Addison-Wesley, 1999, ISBN: 0-201-30998-X.
  7. Hassan Gomaa, Software Modeling and Design, Cambridge University Press, 2011, ISBN: 978-0-521-76414-8.

Sample Class Diagram:

Figure 3. Sample Class Diagram taken from reference #6.