ibm Rational Rhapsody 7.5 — Generating class code

Making a class an instance Making a class an instance To make a class an instance in an OMD, select the Instance tab in the Features window. If the class represents an instance, select the This box is also an instance check box. This is equivalent to giving the class an instance name in the OMD. If this box is checked, the following boxes become active: Љ Instance Name specifies the name of the instance. Љ Multiplicity specifies the number (or range) of times to instantiate the class. The multiplicity indicates the number of instances that can participate at either end of a relation.

Multiplicity can be shown in terms of a fixed number, a range, or an asterisk (*), meaning any number of instances including zero. Defining class behavior To define the behavior of a class, you give it either a statechart or an activity diagram: 1. In the OMD, right-click the class 2. Select either New Statechart or New Activity Diagram . For more information on these diagrams, see Statecharts or Activity diagrams . Generating, editing, and roundtripping class code Rational Rhapsody enables you to generate code and open a text editor for editing the generated code directly from within an OMD. The following sections describe these tasks in detail.

Generating class code To generate code for a single class: 1. Right-click the class and then select Generate . 2. If a directory for the configuration that the class belongs to has not yet been created, Rational Rhapsody asks if you want to create the directory. The configuration directory is under the component directory. Click Yes . 3. Rational Rhapsody creates the configuration directory and generates the class code to it. An output window opens at the bottom of the Rational Rhapsody window for the display of code generation messages. Rational Rhapsody 85