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

Chapter 12: Introduction to Code Generation and Reverse Engineering Using Rational Rose

Round−Trip Engineering

When you generate code using Rose, there are identification numbers placed in the generated code. For example, you may see a line like this in the code:

@roseuid 36730C530302

These strings of numbers and letters are used to help identify the classes, operations, and other model elements in the code and to synchronize the code with your Rose model.

In addition to the ID numbers, Rose generates protected regions in the code during the code−generation process. Any code you write in these protected regions will be safe during round−trip engineering.

For example, let's look at a portion of C++ code that was generated by Rose:

void SampleClass::DoSomething ()

{

//## begin SampleClass::DoSomething%36EAB3DB03AC.body preserve=yes // — Code for the operation goes here —

//## end SampleClass::DoSomething%36EAB3DB03AC.body

}

When the developers write code for this class, they code the DoSomething operation in the space between the //begin and //end statements, in a protected region. If this class is reverse engineered, changes are made, and it is then regenerated, the code of the DoSomething operation will remain safe.

Note When reverse engineering, Rose only examines files. It does not keep any of the source code, such as operation code, stored within Rose.

Summary

In this chapter, we presented an overview of the code−generation and reverse−engineering capabilities of Rose.

To review, the steps for generating code are as follows:

1.

Check the model.

2.

Create the components.

3.

Map the classes to the components.

4.

Set the code−generation properties.

5.

Select a class, component, or package.

6.

415

Chapter 12: Introduction to Code Generation and Reverse Engineering Using Rational Rose

Generate the code.

When reverse engineering code, Rose gathers information about the classes, attributes, operations, and relationships between the classes to generate the appropriate model elements. Using round−trip engineering, you can modify the model and then change the corresponding code, or change the code directly and then update the model. Either way, round−trip engineering helps keep your code and object model synchronized. In the next chapters, we'll take a look at code generation and reverse engineering in more detail for specific languages.

416