If you use both UML models and Java to plan and develop a system, you can use transformations and their reverse transformations to merge and synchronize your work.
In Rational® modeling products, the functionality for merging changes between Java and UML changed in version 7.5.4.
For example, the following use case shows a typical workflow and the results of merging development changes between Java and UML in product versions that were earlier than 7.5.4.
If you developed your system in both Java code and UML models, you would typically expect to follow this workflow to keep changes between the two synchronized:
If you followed this workflow, your attempt to merge the changes that you made to UML model elements that the Java-to-UML transformation generated from the Java elements that you added would fail. The UML-to-Java transformation could not propagate the UML changes to the Java code because the Java elements that you added manually do not have the @generated tags that are required for UML-to-Java transformation to merge UML changes into Java. The UML-to-Java transformation would not override the code without the @generated tags, so the changes you made in UML would not merge into the Java code. To work around this issue and synchronize the model with the code, you must manually add @generated tags to each new code element, and then run the UML-to-Java transformation.
To synchronize your changes between Java and UML, you would need to follow this workflow, which involves an additional step:
Example after version 7.5.4
In version 7.5.4 and later of Rational modeling products, you can instruct the UML-to-Java transformation to overwrite elements (attributes) in Java code. This feature, which you invoke by clicking Link Java to UML, automatically adds @generated tags to Java elements that you created manually, so that the UML-to-Java transformation can propagate the UML changes to Java. This option also adds other Java transformation javadoc comments and preserves existing method bodies by adding //begin-user-code and //end-user-code comments. When you click Link Java to UML, the Java elements are linked to their corresponding UML model elements and the UML-to-Java transform can overwrite the corresponding source code elements. After you click this button, subsequent transformations merge as you expect, because the Java elements are linked to the corresponding model elements.
In version 7.5.4 and later, this is the workflow you follow to synchronize changes between Java and UML: