Operations

In Unified Modeling Language (UML) visualization 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.).

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.

 

Parent topic

About UML class diagrams

 

Related concepts

Class diagrams
Class shapes
Classifiers
Classes
Relationships
Attributes
Adornments for unresolved references
Multiplicity
Visibility

 

Related tasks

Changing the default for showing attribute and operation compartments
Changing the default visibility style for attributes and operations
Showing operation signatures of classifiers