Code Generation

I l @ ve RuBoard

Step 1: Assign the Visual C++ or Visual Basic Language to the Components

Components must be assigned a language. The language of a component is set for all classes assigned to the component.

ASSIGNING A LANGUAGE TO A COMPONENT IN RATIONAL ROSE

graphics/quatranirose_icon.gif
  1. Right-click to select the component in the Browser or on a diagram and make the shortcut menu visible.

  2. Select the Open Specification menu command.

  3. Click the arrow in the Language field to make the drop-down menu visible.

  4. Select the desired language.

  5. Click the OK button to close the Specification.

The Component Specification for the ProfessorCourseOptions component is shown in Figure B-1.

Figure B-1. Component Specification

graphics/bfig01.jpg

Step 2: Assign Classes to Components

Once components have been created, classes are assigned to the components. The components represent either a Visual C++ or a Visual Basic project.

ASSIGNING CLASSES TO COMPONENTS IN RATIONAL ROSE

graphics/quatranirose_icon.gif
  1. Right-click on the component in the Browser or on a Component Diagram to make the shortcut menu visible.

  2. Select the Open Specification menu choice.

  3. Select the Realizes tab.

  4. Right-click on the class to be assigned to the component to make the shortcut menu visible.

  5. Select the Assign menu choice.

  6. Repeat steps 4 and 5 for each class to be assigned to the component.

The component specification for the ProfessorCourseOptions component is shown in Figure B-2.

Figure B-2. Realizes Tab of a Component Specification

graphics/bfig02.jpg

Step 3: Use the Model Assistant Tool to Set Code Generation Properties

The Model Assistant Tool maps modeling elements in Rational Rose to Visual C++ or Visual Basic constructs. In Visual Basic, the Model Assistant Tool may be used to create and specify constants, declare statements, event statements, enum and type declarations, properties, methods , and method parameters. It also allows you to create Get, Let, and Set procedures for class properties and association roles, and to define and create a user -defined collection class for the class. In Visual C++, the Model Assistant Tool may be used to create and specify class operations like constructors and destructors as well as accessor operations for the attributes and relationships.

The Preview field displays the code to be generated for a selected member. This allows you to see how your code generation settings will be applied to the member.

The Model Assistant is available for when

  • The default language for a model is set to Visual Basic or Visual C++

  • The class is assigned to a Visual Basic or Visual C++ component

Detailed information about the Model Assistant Tool may be found in the Rational Rose Help files.

TO START THE MODEL ASSISTANT TOOL

graphics/quatranirose_icon.gif
  1. Right-click to select the class in the Browser or on a class diagram and make the shortcut menu visible.

  2. Select the Model Assistant menu choice.

The Model Assistant Tool for a class assigned the Visual Basic language is shown in Figure B-3. The Model Assistant Tool for a class assigned the Visual C++ language is shown in Figure B-4.

Figure B-3. Visual Basic Model Assistant

graphics/bfig03.jpg

Figure B-4. Visual C++ Model Assistant

graphics/bfig04.gif

Step 4: Select the Components and Use the Code Update Tool to Generate the Code

The Code Update Tool is used to generate the Visual C++ or Visual Basic code. Code may be generated for all components in a package, a single component, or a set of components.

TO START THE CODE UPDATE TOOL

graphics/quatranirose_icon.gif
  1. Right-click on the component in the Browser or on a component diagram to make the shortcut menu visible.

  2. Select the Update Code menu choice.

The Code Update tool is shown in Figure B-5.

Figure B-5. Code Update Tool

graphics/bfig05.jpg

Detailed information about the Code Update tool may be found in the Rose Help files.

Step 5: Evaluate the Code Generation Errors

When the code generation process is complete, the Summary window is displayed in the Code Update tool. The Summary tab contains information about the generated code and all code generation errors are written to the Log, which can be viewed by selecting the Log tab of the Summary window.

The Summary window is shown in Figure B-6.

Figure B-6. Summary Window

graphics/bfig06.jpg

I l @ ve RuBoard


Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net