Skip to content

Methods

General

Operations are used in UML diagrams to specify the behavior of a class. Please note that while the UML specification treats operations and methods (the actual implementations of an operation) differently, UMLBoard - to keep things simple - makes no distinction between the two terms. Operations (or methods) in UMLBoard contain the following elements: The operation's name, a list of parameters, and the return type.

To determine the uniqueness of an operation, UMLBoard only considers its name and the number and order of its parameter types. Therefore, the following two operations would be considered equal, albeit having divergent parameter names:

// both methods will be considered equal as the parameter names 
// are not considered as part of the signature by UMLBoard.
change(firstName: string): void;
change(lastName: string): void;

One way to avoid confusion here could be using more specific operation names.

Creating and Editing

Editing an operation/method works essentially the same way as editing properties. Pressing Tab in an input field moves the cursor to the following input while pressing Enter confirms the current changes and immediately moves the cursor to the method's return value. Pressing Enter again completes the entry.

Summary of method editing

A schematic overview of method editing: TAB lets you step through your method parameters. ENTER takes you directly to the return type.

Note that if you're editing the last parameter type, pressing Tab will immediately create a new parameter and place the cursor on its name.

A new parameter is created while the user presses the tab key on a parameter's type

Pressing the tab key on a parameter's type will create a new parameter.

When creating new methods, however, there is a significant difference compared to properties: While a new property is added immediately to a class, methods are only added after the entire input has been completed by pressing the Enter key on the method's return type. If you cancel editing earlier with Esc, your newly created operation will not be added to your class.

Methods and their parameters also track changes to other classes when referenced. So whenever you delete a class that is the return type of a method, the corresponding method will automatically be deleted. The same also holds for all parameters with the same type.

A parameter is automatically deleted when its type is removed

Deleting a class will automatically remove all parameters that reference this class.

References and further readings


  1. Customizing these rules will be possible in future versions. 


Last update: January 19, 2022