Generating code in code-centric mode

When working in the IBM® Rational® Rhapsody® model-centric mode, if you select Code > Generate, the product generates all new files for the files/classes you have specified, whether it is selected classes, a specific configuration, or the entire project.

About this task

In code-centric mode, the code-generation behavior of Rational Rhapsody is based on the premise that if you add any code-related elements to your model, you would prefer that the product makes as few changes as possible to your code. So if you use the Generate option in code-centric mode, the product does not regenerate the entire file. Rather, it generates only the code segments that represent the new elements that were added and inserts them in the appropriate location in your code. The rest of your code remains exactly as it was.

This principle of minimal intrusion into your code results in a number of other differences in code generation behavior, relative to code generation in model-centric mode:

Other code-generation behavior in code-centric mode:

Note: The code-centric modes selective code updating is only available when using the IBM Rational Rhapsody Advanced code generation setting. The code-centric mode cannot be used with older models unless you change the CodeGeneratorTool property from to Advanced.
Note: When working in code-centric mode, code is not generated for statecharts or activity diagrams.

Code regeneration in code-centric mode: The Generate menu option starts the selective code generation process. However, the Regenerate option will regenerate the entire file. If you use the Regenerate option to generate an entire file, the IBM Rational Rhapsody selective code update feature will not be used until you have roundtripped the file.

Because source code files might contain elements that cannot be brought into a Rational Rhapsody model, if you decide to delete your code and regenerate all the code from your model, the code will not look the same as your original code and might not even compile. The same is true if you set a new Directory for your component - in such a case Rational Rhapsody will regenerate all the code and this code will not necessarily include everything that was in your original code, leaving open the possibility that the code might not even compile.


Feedback