UML operations to Java operations

Bx Examples Repository

Title: UML Operations to Java Operations

Version: 0.1

Type: Industrial, Sketch


The example is a very simple one concerning the consistency between UML class diagrams and the respective Java code. The excerpt we deal with only considers operations and their parameters, and is meant to show the complexity of consistency checks rather than the complexity of a forward or backward transformation.


A left model $m$ is a set of UML operations (that belong to the same class), a right model $n$ accordingly its isomorphic Java counterpart. The figure below depicts exemplarily two operations (as UML and Java model that are consistent to each other). Both operations are named substring. One of the operations has one parameter (beginIndex) where the other one has two parameters (beginIndex and length).



Consistency holds iff a left and right model are isomorphic (including the name attributes of operations and parameters).

Consistency Restoration

A naïve strategy for consistency restoration (in forward or backward direction) is to create missing operations and paramateres on the target side of the transformation, and to delete superfluous ones violating the isomorphy.
We, however, believe that, before deciding for any kind of manual or automated action for consistency restoration, a trace-based consistency check must be performed to indicate which parts of the models have already a counterpart and which parts violate consistency.

In fact, a mental or tool-supported consistency check between two models in this example is likely to require backtracking. In the figure below, two possible outcomes of a top-down mapping of model elements without backtracking are depicted with explicit traces between models. The result on the left shows a correct outcome identifying all elements as consistent whereas the result on the right exhibits wrong mappings of substring operations which are noticed first on the level of parameters.


Variants [optional section]

Additional information to left or right models can be added without a counterpart on the other side (e.g., implementation code in Java operations which is not presented in the UML model). This would introduce "information loss" characteristics to the scenario and make it also interesting for synchronization (and consistency check).


The example was used to show that consistency check is likely to be a more difficult task than forward (backward) transformation, at least for Triple Graph Grammars which need additional control mechanisms to avoid backtracking in consistency checks. It remains to investigate how other bx approaches behave in such cases.


Erhan Leblebici



Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.