Auxiliary Correspondence Model
This is a bx pattern.
Application Conditions
For bx transformations it is often
essential to know which source and
target elements are related to each
other: for each target element,
which source element(s) it has
been derived from. This information is
needed both for effective change-propagation and to resolve
ambiguities when operating a
transformation in the reverse
direction.
Solution
Define
auxiliary entity types and
associations which link corresponding
source and target elements.
These auxiliary elements
are used to record the mappings
performed by a bx, and to propagate
modifications from source to related
target elements or vice-versa, when one
model changes.
Benefits
The pattern is a significant aid
in change-propagation between
models, and helps to ensure the
correctness of a bx. Feature value
changes to a source element s can be
propagated to changes to its
corresponding target element,
and vice-versa,
via the links. Deletion of an element
in one model may
imply deletion of its corresponding element in the other model.
Disadvantages
The
correspondence metamodel must be
maintained (by the transformation
engineer) together with the source
and target languages, and the necessary
actions in creating and accessing
correspondence elements adds
complexity to the transformation and
adds to its execution time and memory
requirements.
Related Patterns
This pattern is a specialisation of the
Auxiliary Metamodel pattern.
Examples
This
mechanism is a key facility of Triple Graph Grammars (TGG),
and correspondence traces are
maintained explicitly or implicitly
by other MT languages
such as QVT-R.
This pattern could also be used
to record sequences of rules applied, in
the case of refactoring or other
update-in-place transformations,
in order to invert these
transformations
by applying inverse rules in reverse
order (eg., reversing a Pull-up Attribute
refactoring by a Push-down Attribute
refactoring).
In UML-RSDS the pattern is applied by
introducing auxiliary attributes into
source and target language
entity types. These attributes are
primary key/identity attributes for the
entity types, and
are used to record source-target
element correspondences.
Target element
t : Tj is considered to correspond to
source element(s) s1 : S1, ...,
sn : Sn if
they all have the same primary key values:
t.idTj = s1.idS1, etc. The identity
attributes are usually
String-valued.
The existence of identity attributes
facilitates element lookup by using the
Object Indexing pattern,
which defines maps from String
to each entity type, permitting
elements to be retrieved by the value
of their identity attribute:
Tj[v] denotes the Tj instance t
with t.idTj = v if v is a single
String value, or the collection of Tj
instances t with v->includes(t.idTj)
if v is a collection.
The pattern can be used to define
source-target propagation and
incremental application of a
transformation tau.