IBM Support

General information regarding enhancements made for Initializer List in Rhapsody v8.0.6

Question & Answer


What are enhancements made for Initializer List in IBM Rational Rhapsody v8.0.6?


Enhancements made for Initializer List in Rhapsody v8.0.6 is not widely available.


In Rhapsody 8.0.6, the ordering capability of constructor's initializer list was improved. As result, you can now sort the order of initialized members (e.g. members, association ends , user code) as you wish to be by moving up and down elements mapped inside Source Artifact.

This enhancement was introduced aiming to prevent potential compiler warnings related to the ordering.

For example, you have the following model:

Supposed that you want to generate the code from BEFORE to AFTER:


B::B() : a0(0), a1(1), a2(2), itsA(aaa) {


B::B() : itsA(aaa), a2(2), a1(1), a0(0) {

Note: The order of members and association end is reversed.

The below is the steps to achieve the code in AFTER:

  1. Turn on Menu > View > Browser Display Options > Show Source Artifacts

  2. Add Source Artifact to class B from Add-New context menu.

  3. Repeat the Step 3. You will see Source Artifacts B.h/B.cpp to be added under class B.

  4. Open Active Code View for class B and run RoundTrip, Source Artifacts will be updated as below:

  5. Change the order of mapped elements as below by using Up/Down button on the top-right corner:

  6. Generate the code, you will see the code below:

    B::B() : itsA(aaa), a2(2), a1(1), a0(0) {

As another enhancement, if you add a constructor to class B and specify the initial value for the attribute a1 to 111, the default initial value will be overridden by the value specified in "Initializer" field. This was not possible in pre-8.0.6 releases.

To disable the new improvement, you can set the value of the property OrderedConstructorInitializer to False.

Note that you can always control the way how the initializer list is generated by setting DisableAutoGeneratedInitializer to True.

This way, the generated initialization code will be the exact code that you entered in the "Initializer" field in the Features window for the constructor.

See the property definition of DisableAutoGeneratedInitializer for more information.

[{"Product":{"code":"SS7P9W","label":"Rational Rhapsody"},"Business Unit":{"code":"BU005","label":"IoT"},"Component":"Documentation","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"8.0.6","Edition":""}]

Document Information

Modified date:
16 June 2018