IBM Support

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

Question & Answer


Question

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

Cause

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

Answer

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:

BEFORE

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

AFTER

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":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Documentation","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"8.0.6","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21670515