Create Workbench Variables

Return to Introduction  Previous page  Next page

Right-click on a Class node in the Project Browser window and select the Create Workbench Instance menu option, or press [Ctrl]+[Shift]+[J]. The menu option is also available from within a Class diagram.


Naming the Workbench

When you elect to create an instance of a type Enterprise Architect prompts you with the Workbench dialog to name the variable. Each instance name must be unique for the workbench.


Choosing a Constructor

Having given the variable a name, you must now choose which constructor to use.

If you do not define a constructor, or define a single constructor taking no arguments, the default constructor or the defined constructor is automatically invoked.

Otherwise the following dialog displays. Select the constructor from the drop-down list and fill in any parameters required.



In the dialog above, type any parameters required by the constructor.

·Literals as arguments
·Text:         abc or 揳bc?or 揳 b c?/span>
·Numbers:        1 or 1.5
·Objects as arguments

       If an argument is not a literal then you can supply it in the list only if you have already created an instance of that type in the workbench. You do this by typing the name of the instance as the argument. The debugger checks any name entered in an argument against its list of workbench instances, and substitutes that instance in the actual call to the method.

·Strings as arguments

       Surrounding strings with quotes is unnecessary as anything you type for a string argument becomes the value of the string; for example, the only time you should surround strings with quotes is in supplying elements of a string array, or where the string is equal to the name of an existing workbench instance.

               揂 b c?/span>

               揳 b $ % 6 4 ?/span>

               A b c d

               As 5 7 ) 2 === 4

·Arrays as arguments

       Enter the elements that compose the array, separated by commas.

               Type                Arguments

               String[]                one,two,three,攁 book?攁 bigger book?/span>

               CPerson[]        Tom,Dick,Harry

Note: If you enter text that matches the name of an existing instance, surround it in quotes to avoid the debugger passing the instance rather than a string.



Having chosen the constructor and supplied any arguments, click on the Invoke button to create the variable. Output confirming this action is displayed in the Output tab.