Classes

A class is a Unified Modeling Language (UML) diagram element that represents an application element. An application element can be represented by multiple instances of a class in one or more diagrams.

You use classes to illustrate conceptually related application elements in diagrams. A class diagram element shows all or part of the underlying semantics. A class diagram element identifies the attributes, operations, relationships, and semantics that instances of the class possess. Every object that instantiates a class usually provides its own attribute values. Attributes are also called variables, member variables, properties, and fields, but are usually implemented as variables.

Each class diagram element has properties that govern its appearance and location in a diagram. Modifying properties of a diagram element only changes the appearance of the element and does not affect the underlying semantics or any other diagram element that represents that application element.

As the following figure illustrates, a class is displayed in a diagram as a rectangle with three compartments:

The image represents a Java class in a diagram.

You can show, hide, or collapse the attribute and operation compartments. You can use additional compartments to display other details such as constraints or signals that instances of the class can receive.

The classes in an application usually appear in class diagrams. You can add classes or instances of classes (objects or classifier roles) to diagrams to represent the following items:

Example

An e-commerce application might include a Cart class. The class defines an itemList attribute, and an addItem operation that belong to all objects of type Cart. At run time, multiple instances of the Cart class might be created, each possessing the attributes and operations that the class defines. The values of the attributes for each instance will differ if, for example, one class object calls the addItem operation to add videos to its itemList attribute, while another instance uses the same operation to add books.

Related concepts
Class diagrams
Classifiers
Related tasks
Setting the default for showing parent names
Showing parent names of classifiers
Creating Java elements
Deleting Java elements
Editing Java elements
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.