<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Elementary Model Management Patterns</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Sahar Kokaly</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Zinovy Diskin</string-name>
          <email>zdiskin@gsd.uwaterloo.ca</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Tom Maibaum</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Hamid Gholizadeh</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>NECSIS, McMaster University</institution>
          ,
          <country country="CA">Canada</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Waterloo</institution>
          ,
          <country country="CA">Canada</country>
        </aff>
      </contrib-group>
      <fpage>2</fpage>
      <lpage>6</lpage>
      <abstract>
        <p>Model management tools contain common aspects that are frequently reinvented for each tool. Platform speci c solutions to common problems may vary by language, however, the high-level speci cations should be the same. Design patterns seek to communicate these common speci cations in an abstract way that enables reuse, improves understanding and eases communication. In this paper, we present a library of fundamental design patterns based on mathematical foundations that are used as building blocks to specify more complex patterns which describe more concrete model management scenarios.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        Design patterns appear in many areas of software engineering including Object
Oriented (OO) design [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and work ow languages [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], and can be used for model
management (MMt) as well. Indeed, MMt tools address common issues, whose
solutions are frequently reinvented for each tool. Platform speci c solutions to
common problems may vary by language, however, the high-level speci cations
could be the same. Design patterns seek to communicate these common
speci cations in an abstract way that enables reuse, improves understanding, and
eases communication.
      </p>
      <p>
        Although some work has been suggested in the literature relating to
design patterns for MMt, most of it has focused on model transformation (MT)
design patterns, and has been speci c to certain MT languages. In a notable
work [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], the authors propose a platform independent language for describing
patterns for graph-based MTs. In [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], the author discusses transformation
patterns for refactoring/improving/implementing OO designs. In our earlier work
[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], we presented a library of abstract design patterns for MMt based on
mathematical foundations. Rather than suggesting patterns for entire MMt scenarios
(as is done for OO design in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and for MT in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]), we proposed elementary
building-block-patterns, from which complex patterns for MMt scenarios can be
composed. The goal of this short paper is to introduce the library to the PAME
community, and present it in a condensed and simpli ed way (Section 2). How
our elementary patterns are composed into complex scenarios is shown by an
example in Section 3.
In our presented design patterns, mappings are made explicit and are de ned
as sets of links (block arrows) between model elements rather than single links
between models. Moreover, the algebraic operations (appearing on chevrons) in
the patterns generate models as well as explicit traceability maps.
      </p>
      <p>Patterns 1-3 present a given con guration, and we call them static. In these
patterns, we provide a clear separation between the information that is given
(shown in black) and that being provided by a user or some heuristics (shown in
green). In contrast, patterns 4-8 show operations, which take a con guration of
models and mappings as their input (shown by shaded elements that are either
black or green), and output a con guration of automatically computed models
and mappings (blank blue elements). We call these patterns dynamic. Amongst
them, patterns 4-6 are for source-to-target MTs, and patterns 7,8 are for the
two types of model merge operations.</p>
      <p>Pattern 1: Typing Mapping. A model is a total typing mapping (e.g., t1 in
Fig.1) from a model's data graph (D1) to the model's metadata graph (M M1)
(ovals in Fig.1). Typing must satisfy the constraints (C1) declared in the
metamodel (we write t1 j= C1). Three vertical arrows in Fig.1 specify three models.
Pattern 2: Model Mapping. A model mapping (e.g., f1 in Fig.1) is a pair
(f1D, f1MM ) of total correspondence mappings between the respective data and
metadata parts of the models. Together with the respective typing mappings,
they form a commutative square of graph mappings. E.g., in Fig.1, we have
two commutative squares (note the marker [=]) specifying two model mappings:
fi : M0 ! Mi; i = 1; 2.</p>
      <p>Pattern 3: Model Overlap. An overlap of two models is a span of model
mappings. E.g, Fig.1 speci es a span (f1; f2) between models M1 and M2. Model
M Mo, the head of the span, comprises correspondence links between models,
and mappings fi; i = 1; 2 point to the ends of the links.</p>
      <p>M1
MM1
t1 |= C1</p>
      <p>D1
f1MM
[=]
f1D
f2MM
[=]
f2D</p>
      <p>M2</p>
      <p>MM2
t2 |= C2</p>
      <p>D2
Mo
MMo
to |= Co</p>
      <p>Do
Pattern 4: Descriptive Views. A view de nition is a metamodel mapping
v1 : M M1 M Mo (see Fig.2). Its execution for model M1 is given by invoking
the operation vExe (note the chevron), which takes instances of M M1 and
outputs instances of M Mo.</p>
      <p>Pattern 5: Prescriptive Views. Implementation of an instance of metamodel
M Mo within a platform speci ed by M M2 is an operation opposite to view
execution (see Fig.2), and unfolds over a view de nition mapping v2 : M Mo ! M M2.
We call this operation source generation sGen. As view models (e.g., Mo) usually
contain less information than source models (e.g., M2), a policy is required to
choose a unique implementation amongst all possibilities.</p>
      <p>Pattern 6: Model Transformation. A model transformation de nition is,
in general, a span (v1; v2) of metamodel mappings, which can be executed in
both directions. Fig.2 shows execution of the span in the direction from left to
right, which transforms model M1 into model M2. The span can be also executed
in the opposite direction with vExe for v2 and sGen over v1. View execution and
source generation are two special cases, when either the right or the left \leg" of
the transformation de nition span is the identity mapping.</p>
      <p>
        Pattern 7: Additive Model Merge. An Additive Merge is the result of
executing a colimit operation on two models and their correspondence span, resulting
in a model together with two embedding mappings ei; i = 1; 2 (as seen in Fig.3),
whose inverse mappings provide traceability. This operation accurately merges
elements of the models without redundancy: if an element x from model M1 and
y from model M2 are linked in the correspondence span O, only one element
appears in the colimit M1 _ M2. Real model merge typically requires some
postprocessing for con ict resolution and normalization (see [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] for details).
      </p>
      <p>M1
MM1
:vExe
f1D
v2
f2D</p>
      <p>M2</p>
      <p>
        MM2
to |= Co :sGen
M1∨M2
M1
:limit
tr1
M1ΛM2
Pattern 8: Multiplicative Model Merge. A Multiplicative Merge is the
result of executing a limit operation on two models and their correspondence
co-span, resulting in a model together with two traceability mappings (see Fig.4)
to each of the input models. This pattern appears in scenarios that involve model
parallel composition, intersection or join. Details can be found in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
3
      </p>
    </sec>
    <sec id="sec-2">
      <title>Example</title>
      <p>Consider the following MMt scenario: two models M 1,M 2 are matched, then
merged, and the merge is translated into code. In our framework, the work ow
is encoded as a composition of operations shown in Fig.(5). Semi-automatic
(green) operation Match produces the correspondence span O, operation Merge
(comprising colimit with some post-processing not shown in the gure) results
in a triple (M 3; e1; e2), and operation Transf (whose de nition is not shown)
produces M 4 with traceability mapping tr. Finally, applying operation limit to
the cospan (e1; tr) outputs M14; the part of M 4 that depends on M 1.
user input
heuristics</p>
      <sec id="sec-2-1">
        <title>1: Match</title>
        <p>O
M1
M2
e1</p>
      </sec>
      <sec id="sec-2-2">
        <title>2: Merge</title>
        <p>e2</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Concluding Remarks</title>
      <p>As an exercise, we encourage the workshop participants to consider the MDE
design patterns they proposed in light of the patterns we presented here.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>van der Aalst</surname>
            ,
            <given-names>W.M.P.</given-names>
          </string-name>
          :
          <article-title>Work ow patterns</article-title>
          .
          <source>In: Encyclopedia of Database Systems</source>
          , pp.
          <volume>3557</volume>
          {
          <issue>3558</issue>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Diskin</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kokaly</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maibaum</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Mapping-Aware</surname>
            <given-names>Megamodeling</given-names>
          </string-name>
          :
          <article-title>Design Patterns and Laws</article-title>
          . In: SLE. pp.
          <volume>322</volume>
          {
          <issue>343</issue>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Diskin</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maibaum</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>A model management imperative: being graphical is not su cient, you have to be categorical</article-title>
          . (To appear
          <source>in ECMFA'15)</source>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Ergin</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Syriani</surname>
          </string-name>
          , E.:
          <article-title>Towards a language for graph-based model transformation design patterns</article-title>
          .
          <source>In: Theory and Practice of Model Transformations - 7th International Conference, ICMT 2014</source>
          , York, UK,
          <source>July 21-22</source>
          ,
          <year>2014</year>
          . pp.
          <volume>91</volume>
          {
          <issue>105</issue>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Gamma</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Helm</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          , Johnson, R.,
          <string-name>
            <surname>Vlissides</surname>
          </string-name>
          , J.:
          <article-title>Design patterns: elements of reusable object-oriented software</article-title>
          .
          <source>Pearson Education</source>
          (
          <year>1994</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Lano</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kolahdouz-Rahimi</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Design patterns for model transformations</article-title>
          .
          <source>In: ICSEA</source>
          <year>2011</year>
          ,
          <source>The Sixth International Conference on Software Engineering Advances</source>
          . pp.
          <volume>263</volume>
          {
          <issue>268</issue>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>