Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Mastering UML with Rational Rose 2002.pdf
Скачиваний:
137
Добавлен:
02.05.2014
Размер:
9.68 Mб
Скачать

Chapter 15: Visual Basic Code Generation and Reverse Engineering

The Option Base, Option Explicit, and Option Compare properties can be set using the Options tab of the Model Assistant, as shown in Figure 15.3.

Figure 15.3: Using the Model Assistant's Options tab to set class properties

Using the Template tab, you can control whether debug code is added to the Initialize and Terminate events of the class, whether "Your code goes here…" comments are added to the class methods, and whether error−handling code is added to the class methods. By default, all of these are set to False. Some class stereotypes have additional fields that can be set using the Template tab. We will discuss those in the upcoming "Classes" section under "Generated Code."

Attribute Properties

Attribute properties are the Visual Basic properties that relate specifically to attributes. Using these properties, you can, for example, decide whether the attribute will be generated in the code, what the attribute name should be in the generated code, and whether Get, Set, or Let operations should be created for the attribute.

498

Chapter 15: Visual Basic Code Generation and Reverse Engineering

There are three places to set these properties. To set them for all attributes, select Tools → Options, then click the Visual Basic tab and select Attribute from the drop−down list box. To set them for only one attribute, select the Visual Basic tab on the attribute specification window and edit the properties there, or use the Model Assistant.

Table 15.2 lists the attribute properties, their purposes, and their default values.

Table 15.2: Attribute Code−Generation Properties

Property

Purpose

Default

New

Controls if the attribute is generated with a new modifier

False

WithEvents

Controls if the attribute is generated with the With Events

False

 

modifier

 

ProcedureID

Sets the Visual Basic procedure ID

<blank>

PropertyName

The name of the property to which the attribute belongs

<blank>

Subscript

Sets the array subscript to use when generating data members for

<blank>

 

the attribute

 

As you can see in Figure 15.4, you can set the attribute visibility and data type using the Model Assistant. You can also set the New, WithEvents, and Subscript properties using this window.

Figure 15.4: Using the Model Assistant to set attribute properties

Underneath each attribute in the treeview section of the Model Assistant, you can see the Get and Let options. Selecting these will control whether Get and Let methods will be created for this particular attribute. After you select the methods you'd like to generate, you can set additional information for the methods using the Model Assistant. This information is discussed in the following section, "Operation Properties."

Operation Properties

The operation properties are the Visual Basic code−generation properties that are specific to operations. These properties will let you set the name of the operation, control whether the operation is static, and set other code−generation specifications for each operation.

499

Chapter 15: Visual Basic Code Generation and Reverse Engineering

There are three places to set these properties. To set them for all operations, select Tools → Options, then click the Visual Basic tab and select Operation from the drop−down list box. To set them for only one operation, select the Visual Basic tab on the operation specification window and edit the properties there, or use the Model Assistant.

Table 15.3 lists the operation code−generation properties, their purposes, and their default values.

Table 15.3: Operation Code−Generation Properties

Property

Purpose

Default

LibraryName

Sets the name of library in which to generate the operation

<blank>

AliasName

Sets the name of an operation alias

<blank>

IsStatic

Controls if the operation is static

False

ProcedureID

Sets the Visual Basic procedure ID

<blank>

ReplaceExistingBody

Specifies whether to overwrite existing body code with the

False

 

default body code

 

DefaultBody

If ReplaceExistingBody is True, specifies the default text (code

<blank>

 

and comments) to include in the body

 

Figure 15.5 shows the Model Assistant window for an operation.

500

Chapter 15: Visual Basic Code Generation and Reverse Engineering

Figure 15.5: Using the Model Assistant to set operations

As noted earlier in this chapter, this window is used not only for operations you've defined, but for the generation of Get and Let methods for the attributes as well. Let's look at what can be set on this screen:

Access Level field sets the visibility of the operation (public, private, or friend).

Type field sets the return type of the operation.

Static field corresponds to the IsStatic property.

Replace Existing Body field corresponds to the ReplaceExistingBody property.

DefaultBody field corresponds to the DefaultBody property. Note that for Get and Let operations, Rose provides code in this field for you.

Using the Parameters tab, you can add or remove parameters, and set the following for each parameter:

Data type (Type field)

Initial value (Initial Value field)

Whether or not the parameter is optional (Optional field)

Whether the parameter is passed by value or by reference (ByRef and ByVal fields)

501