UML Modeling Techniques > Class modeling > Operations > Using an operation signature to specify properties and parameters
  
Using an operation signature to specify properties and parameters
Through the Signature of an Operation, you can perform the following tasks:
Specify the Name of the Operation.
Reference an item to use as the Operation's Return Type.
Create an uninterpreted type to use as the Operation's Return Type.
Create Parameters for the Operation.
Set the Mechanism, Type, Name and Default of each Parameter.
You specify the Return Type, Name and Parameters of an Operation by typing the Signature in the following format:
<operation name> [(<parameters)] : <return type>]
where:
<operation name> - is the Operation's Name.
<return type> - is the Operation's Return Type. Modeler attempts to match the text you type with items that can be used as Return Types in the model. If a match is found, the item is referenced as the Return Type. If no match is found, a Return Type is created as an uninterpreted type. If you do not type any text, void is displayed in the Signature. Ensure that you prefix <return type> with a colon.
<parameters> - is the Operation's Parameters. For each parameter, type the following information:
<mechanism> <parameter name> [: <parameter type>] [= <default>]
where:
<mechanism> is the Parameter's Mechanism. Type either 'in', 'out', or 'in out'. If you do not type a mechanism, Modeler sets the Mechanism to 'in'.
<parameter name> is the Parameter's Name.
<parameter type> is the Parameter's Type. Modeler attempts to match the text you type with items that can be used as Types in the model. If a match is found, the item is referenced as the Type. If no match is found, an uninterpreted type is created. If you do not type any text for <parameter type>, the Type is left blank. Ensure that you prefix the parameter type with a colon.
<default> is the Parameter's Default. If you do not type any text for <default>the Default is left blank.
* 
If the Parameter's signature is greater than 200,000 characters, the Default value is not included in the signature. If the Default value is not included and you change the signature, the Default value will not be changed. If the Default value is not included and you want to clear the Default value through the signature, you must include '= ' at the end of the signature. Ensure that you prefix a default value with an equals character.
You can change the Signature of an Operation in the following ways:
Through the Signature property on an Operation's Property Pages.
Through the Items tab of a Class', Data Type's, Interface's or Signal's Property Pages - change the entry.
Through an Operation appearing on a Class Diagram - right-click the Operation, and then click Edit Signature. When using in-place editing to change a signature on a Class Diagram, use the Ctrl+Enter keys to add a return, and use the Enter key to save the changes.
* 
You can set the return type of an Operation in a Modeler pane by dragging the item you want to be the return type to the Operation. You can set the return type of an Operation on a Class Diagram by dragging the item you want to be the return type to the Operation.
After adding an Operation to a Class on a Class Diagram, you right-click the Operation, click Edit Signature, and then type the following text to replace the default Signature:, Set Attribute Value (in Name : string, in Status : string = NOT SET) : Boolean
The preceding Operation Signature performs the following tasks:
Changes the Name of the Operation to Set Attribute Value.
Sets the Return Type of the Operation to Boolean, referencing the Boolean Basic Type.
Creates Name and Status Parameters for the Operation:
The Mechanism of each Parameter is set to 'in'.
The Type of each Parameter is set to string. In a new model, string will be set up as an uninterpreted Type.
The Default value of the Status Parameter is set to NOT SET.
* 
When a Parameter appears on the Items tab of an Operation's Property Pages, you can specify the Parameter's Mechanism, Type, Name and Default through the <mechanism> <parameter name> [: <parameter type>] [= <default>] syntax.