Class Diagram Definition (UML 1.5)
Go Up to UML 1.5 Class Diagrams
Class diagrams are the most common diagrams found in object-oriented modeling systems.
Contents
Definition
A class diagram provides an overview of a system by showing its classes, interfaces, and collaborations and the relationships among them. Class diagrams are static: they display what interacts but not what happens during the interaction.
In the UML notation, a class is represented as a rectangle divided into several parts: class name, attributes (fields), operations (methods), and others:
In Modeling, the class rectangle is further divided with separate compartments for fields, inner classes, properties, operations, and others:
Names of abstract classes and interfaces are in italics.
Relationships among classes on class diagrams -- generalization (implementation), dependency, and association (simple association, aggregation, composition) -- are represented by the connecting links. These relationships are discussed in Relationships Among Elements of Class Diagrams .
Class Diagrams in Design and Implementation Projects
Using Modeling, you can create language-neutral (UML) class diagrams in design projects, or language-specific (Delphi or C++) class diagrams in implementation projects. Notice that the different sets of elements are available for class diagrams in UML, Delphi, and C++ projects. The lists of available elements can be found in Class Diagram Elements.
For implementation projects, all diagram elements on class diagrams are immediately synchronized with the source code.
Class Diagram Types
There are two types of class diagrams used in the Modeling:
- Package (namespace) diagrams. A diagram of this type represents the contents of a package (namespace). These diagrams are referred to as package diagrams in design projects and namespace diagrams in implementation projects. They are stored as XML files with the
.txvpck
extension in theModelSupport_%PROJECTNAME%
subfolder of the project group. - Logical class diagrams. A diagram of this type represents classes, the relationships among them, and members of these classes. These diagrams are stored as XML files with the
.txvcls
extension in theModelSupport_%PROJECTNAME%
subfolder of the project group.
The Modeling feature automatically creates a default package (namespace) diagram for the project and for each subdirectory under the project directory. The default package (namespace) diagram for the project has the default
name. Other automatically generated default namespace (package) diagrams are named after the respective namespaces (packages).
You create logical class diagrams manually using the Add > Class Diagram or Add > Other Diagram commands on the context menus in the Diagram View or Model View.
Sample class diagram
The following class diagram models a customer order from a retail catalog. The central class is the Order
. Associated with it are the Customer
making the purchase and the Payment
. There are three types of payments: Cash
, Check
, or Credit
. The order contains OrderDetails
(line items), each with its associated Item.
There are three kinds of relationships used in this example:
- Association: For example, an
OrderDetail
is a line item of eachOrder
. - Aggregation (association): In this diagram,
Order
has a collection ofOrderDetails
. - Implementation (generalization):
Payment
is an interface forCash
,Check
, andCredit
.