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

Code Generation - Interaction Diagrams


To be able to generate code from behavioral models, all behavioral constructs should be contained within a Class.

For an Interaction (Sequence) diagram, the behavioral code generation engine expects the Sequence diagram and all its associated messages and interaction fragments to be encapsulated within an Interaction element.

During code generation from Interaction (Sequence) diagrams in a Class, Enterprise Architect applies its system engineering graph optimizer to transform the Class constructs into programmatic paradigms. Messages and Fragments are identified as one of the several action types based on their functionality, and Enterprise Architect uses the EASL code generation templates to render their behavior accordingly. For example:

  • A Message that invokes an operation is identified as an Action Call and is rendered accordingly
  • Combined Fragments are identified by their types and conditions; for instance, an Alt fragment is identified as an Action If, and a loop fragment is identified as an Action Loop.

For more information on the EASL code generation macros and templates Enterprise Architect uses to generate code from behavioral models see the EASL Code Generation Macros topic.

sd newTransaction

The above diagram contains:

  • A Combined Fragment (alt ), which is identified as an Action If
  • An Interaction Occurrence, which is identified as an Action Call with all argument information associated with it, and
  • A message (Action Opaque).

The Java code generated from this diagram resembles the following:

public void newTransaction()


               // behavior is an Interaction

               if (bValidUser)        // Alt combined fragment


                       placeOrder(101); //Interaction Occurrence