Operations
Operations are features of classes that specify how to invoke a particular behavior. For example, a class may offer an operation to draw a rectangle on the screen or count the number of items selected in a list. UML makes a clear distinction between the specification of how to invoke a behavior (an operation) and the actual implementation of that behavior (a method). See "Methods" for more information.
You place operations in a separate compartment with the following syntax:
visibility name ( parameters ) : return-type {properties}
where parameters are written as:
direction parameter_name : type [ multiplicity ]
= default_value { properties }
Figure 2-13 shows several example operations on a class.
Figure 2-13. Example operations on a class
The syntax elements are:
-
visibility
Indicates the visibility of the operation. Use the following symbols: +, -, #, or ~ for
public
,private
,protected
, orpackage
, respectively (see "Visibility" in Chapter 3).-
name
Is a short phrase naming the operation. Operations are usually verb phrases representing actions the classifier should perform on behalf of the caller. The UML specification recommends that the first letter of an operation be lowercase, with all of the following words starting with a capital letter and running together. See Figure 2-13 for an example.
-
return-type
Is the type of information the operation ...
Get UML 2.0 in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.