Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Operation Behavior

You can define the behavior of an operation in one of two ways:

  • As a text description consisting of pseudo-code, structured English or just simple text
  • As a reference to a behavior element, such as an Activity or Interaction, or to another operation

You can set an option to show the behavior text or reference on the depiction of the parent element on a diagram. In this State element example, the entry operation applies the behavior of the ActivityComp Activity, whilst the exit behavior is described in simple text.

You can also define initial code to be inserted into an operation Body when that operation is initially generated to file; after that initial generation the code is no longer used and, if other behaviors have been defined, they are applied instead.

Access In diagram or Project Browser:

Click on element | Element | Operations (F10) > Operations > Behavior    or

Right-click on element | Features & Properties | Operations > Operations > Behavior

Set Behavior


  • In the 'Behavior' field, type the text or code description of the behavior, or
  • Click on the Element button to display the 'Select Behavior' dialog, then browse for and select the appropriate element or operation; when you click on the OK button, the fully qualified object name displays in the 'Behavior' field

If you want to use initial code, click on the Initial Code button and enter the code on the 'Initial Code' screen.

If you want the behavior to be shown on any diagram that the operation appears in, select the 'Show Behavior in Diagram' checkbox.

When you have defined the operation behavior, click on the Save button.

Delete behavior

If you have typed in a behavior description in free text, simply delete the text.

If you have selected another behavioral object, click on the Element button and select the '<none>' option at the foot of the 'Select Element' hierarchy.

Example of Associated Behavior

An operation of, for example, a Class can be associated with a behavior elsewhere in the model. The operation is then set as the specification of that associated behavior. In code generation, the behavior of the associated behavioral element is generated as the operation's code; in this illustration, op1 is associated with the Activity 'Activity'.

The generated code for op1 is as shown:

     package Behavior;

     public class Container {

          public Container() {


          public void finalize() throws Throwable {


          public void op1() {

          /*Activity element(Activity)'s behavior rendered as

               operation(op1)'s code*/


               if (cond1)










          /*Activity element (Activity) not rendered*/

          public void Activity2()


               // behavior is an Activity


          public void Interaction()


               // behavior is an Interaction


     } //end Container

Learn more