Operations

In Unified Modeling Language (UML) class diagrams, an operation requests a service that a classifier or an instance of a class is called to perform. Operations are contained by classes and interfaces. A classifier can have any number of operations or none at all.

Operations are implementations of functions or queries that an object might be called to perform. A well-defined operation does only one thing.

For example, you can make a Cart class responsible for adding and removing merchandise that a client plans to buy. You can then add an addItem( ) operation that adds merchandise to the cart and a removeItem( ) operation that removes merchandise.

In UML class diagrams, Java™ methods map to UML class operations (behaviors).

Operations are shown in the operation compartment of a shape in a UML class diagram. Operations that are defined in the scope of the class, that is static, are shown as underlined. The visibility styles of operations can be represented as text symbols (such as "+") or icons (such as Image showing an Eclipse Protected visibility icon for operations.).

The following figure illustrates how operations are represented with visibility icons in class diagrams.

Java source code UML visualization
The image shows the Java source code that appear as operations. The image shows how operations (methods) of Java classes are represented in UML class diagrams.
Related concepts
Attributes
Visibility attributes in UML diagrams
Related tasks
Setting the default for showing operation signatures
Changing the default for showing attribute and operation compartments
Changing the default visibility style for attributes and operations
Showing operation signatures of classifiers
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.