Planning multiple development language projects

IBM® Engineering Systems Design Rhapsody® uses units to permit projects to contain components from different development languages such as C and C++. Each unit is associated with a specific development language. Several Rhapsody capabilities support multiple-language projects:

  • Rhapsody API: The interface IRPUnit allows recursive changing of unit language.
  • The Rhapsody internal reporter shows the language of each saved unit.
  • XMI: Language of each unit is exported and imported.
  • Graphic Editor: Changes to language of a unit do not affect the depiction of the unit in the graphic editor. For example, if you change the language of a template class to C, it will still look like a template class in the graphic editor.
  • Rhapsody DiffMerge checks for language differences.
  • PredefinedTypes package: These packages are language-dependent. When you create a unit whose language differs from that of the Rhapsody version being used, the relevant package of predefined types for that language will be loaded.

Determining the language of a unit in multiple-language projects

When you create a unit, the Unit Information window provides a list that allows you to select a specific language for the unit. The default language for a new unit is the language of its owner unit.

  1. Right-click the unit in the browser, and then select Unit > Edit Unit.
  2. When the Unit Information window is displayed, select the language from the list.
  3. Click OK.
  4. When you are asked to confirm the change, click Yes.

If you are changing the language of a unit that contains subunits, Rhapsody asks you if you also would like to change the language of all the contained subunits.

Note: As is the case for project migration, if you change the language of a unit, you do not permanently lose any language-specific features of the unit. These language-specific characteristics are not displayed, and any code generation is in the new language. However, the product maintains this information. If at a later stage, you switch the unit back to the original language, you will once again see these language-specific characteristics.

When you move units of one language to a package of another language, the product informs you that they are different languages and asks you to confirm the move.

If you try to add a unit that is associated with another language, Rhapsody asks you to confirm the addition of the unit. You are also prompted for confirmation if you add "by reference" a unit that is associated with another language.

Considerations for generating code for multiple-language projects

Rhapsody Developer for C, C++, and Java can generate code for units. For code generation to work properly, you have to adhere to the following rules:

  • To generate code for units in a certain language, the appropriate language must be specified at the component level.
  • Elements included in the scope of a component must be of the same language as the component. (If other language elements are included in the scope, a warning will be issued during code generation.)
Note: If you select All Elements as the scope, Rhapsody will automatically include only those units whose language matches that of the component. If you choose Selected Elements, the product will only display those units whose language matches that of the component. However, if you selected specific elements, and then changed the language of the component, Rhapsody will not remove the selection of these non-matching units. When you attempt to generate code with such a component, you will receive error messages.
The same principle applies to the Initial Instances specified for the configuration.

Language-specific differences in Rhapsody

The Features window differs among the development languages. For each unit in your model, the appropriate Features window is displayed.

Similarly, the properties that are displayed reflect the development language of the selected unit.

Non-unit elements in multiple-language projects

If you try moving an element that is not saved as a unit to a package with a different language, the language of the element will be changed to that of the receiving package after you confirm that you want to move the element.

Reverse engineering in multiple-language projects

The reverse engineering mechanism always uses the language of the active component. When you use the Reverse Engineering window to add files to reverse engineer, the default file filter used reflects the language of the active component, for example, *.java if the active component is associated with Java.