<!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>Towards an Automated Pattern Selection Procedure in Software Models</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Alexander van den Berghe</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jan Van Haaren</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefan Van Baelen</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yolande Berbers</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Wouter Joosen</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>iMinds-DistriNet, Department of Computer Science, KU Leuven Celestijnenlaan 200A, 3001 Leuven</institution>
          ,
          <country country="BE">Belgium</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Software patterns are widely adopted to manage the rapidly increasing complexity of software. Despite their popularity, applying software patterns in a software model remains a time-consuming and errorprone manual task. In this paper, we argue that the relational nature of both software models and software patterns can be exploited to automate this cumbersome procedure. First, we propose a novel approach to selecting applicable software patterns, which requires only little interaction with a software developer. Second, we discuss how relational learning can be used to further automate this semi-automated approach.</p>
      </abstract>
      <kwd-group>
        <kwd>Relational Learning</kwd>
        <kwd>Software Pattern Selection</kwd>
        <kwd>Logic Programming</kwd>
        <kwd>Application</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>The complexity of both software and the software development process has
increased rapidly over the past decades because of three reasons. The rst reason
is the steadily increasing complexity of the problems that software tackles. The
second reason is the shift towards distributed software, which entails a number of
additional issues to account for. The third reason is the relatively long lifetime of
software, which is often much longer than that of the hardware it was originally
developed for and which requires it to adapt to an ever changing environment.</p>
      <p>
        Software patterns provide established solutions to recurring issues in software
development [
        <xref ref-type="bibr" rid="ref1 ref5">5, 1</xref>
        ] and hence improve the overall quality, portability and
readability of a software design. Although software patterns are widely adopted by
software developers, applying patterns remains a mostly manual two-step task.
First, a developer selects the most appropriate patterns based on his or her
previous experiences. This is an increasingly di cult and time-consuming task
due to the steadily growing number of patterns. Second, a developer instantiates
these patterns in the software design, which is a repetitive and error-prone task.
      </p>
      <p>In this paper, we argue that the relational nature of both software models and
software patterns can be exploited to automate this cumbersome procedure. We
apply inductive logic programming techniques for representing these models and
patterns as well as reasoning about them. First, we propose a semi-automated
approach to selecting applicable patterns in a graphical software model. Our
approach relies on a concise relational representation of both the available
software patterns and a software model. The approach requires only little interaction
with a software developer whereas current pattern selection procedures rely on
an extensive speci cation of the design problem. Second, we brie y share ideas
on how relational learning techniques can further automate our approach and
hence reduce the amount of user interaction.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Background on Software Engineering</title>
      <p>On a very high level, designing software is gathering requirements and ensuring
these requirements are met in the nal software system. Software developers
typically identify a number of components, which each satisfy a subset of the
requirements, in order to manage the complexity of software. Components o er
their functionality through one or more interfaces via which they collaborate.</p>
      <p>
        Software developers formally capture their design decisions in graphical
models. Each model element can be annotated with additional information (e.g.,
implementation details) that is required during the development process. Although
our approach is applicable to multiple types of software models, we restrict
ourselves to the Component-and-Connector Model, which is one of the most
important types of models during software development. Figure 1 shows an excerpt of
a digital newspaper system, inspired by [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], in which clients can browse through
news articles, read news articles and subscribe to speci c categories of news.
      </p>
      <p>Software patterns o er established solutions to recurring design issues.
Alongside a unique name, a software pattern comprises a generic description of both
the design issue it addresses and the solution it proposes (i.e., independent of
any concrete design and/or implementation decision). Furthermore, a software
pattern contains an overview of its consequences and trade-o s, which is helpful
to decide on the most appropriate software pattern.</p>
      <p>
        Automatically selecting applicable software patterns requires a formal
representation of either the design issue a software pattern addresses or the solution it
proposes. Our approach leverages Zdun and Avgeriou's concept of primitives [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]
to formally represent a pattern's proposed solution. Primitives have precisely
de ned semantics and can be seen as building blocks for patterns. A software
pattern combines several primitives to o er a solution to a speci c design issue.
      </p>
      <p>
        Figure 2 shows the Client-Dispatcher-Server pattern, which comprises
the Client, Dispatcher and Server primitives [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
Pattern selection has only been given little attention in academic literature.
Kamp meyer and Zschaler [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] use a pattern intent ontology that can be queried
with design issues and return all applicable patterns. Kim and El Khawand [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]
rst formally model each pattern as a set of pattern-speci c roles and then
determine which patterns are applicable by verifying which roles the software model
ful lls. Hsueh et al. [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] introduce a goal-driven approach that proposes
applicable patterns by asking relevant questions to the developer. Hasheminejad and
Jalili [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] rst classify the patterns and the design issue using text classi cation
and then propose the best matching patterns from the design issue's class.
      </p>
      <p>
        Current pattern selection techniques require either an extensive speci
cation of the design problem (e.g., [
        <xref ref-type="bibr" rid="ref6 ref7 ref8">8, 7, 6</xref>
        ]) or the patterns' problem descriptions
(e.g., [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]), which is often cumbersome and time-consuming, and considerably
limits their usability and reliability. Besides, it is not obvious how to extend
these techniques to new (types of) patterns since either an extensive analysis is
required or the terminology in their description should be chosen carefully.
      </p>
      <p>
        Although automated pattern selection has only been given little attention to
date, the idea of tackling software engineering issues using machine learning is
not new. One area of interest is that of software pattern detection, where the
task is to identify applied software patterns when re-engineering legacy software.
Correa et al. [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] perform this task using Prolog as a representation language.
Another area of interest is that of software testing, where the task is to evaluate
how well software systems meet their speci cation [
        <xref ref-type="bibr" rid="ref11 ref3">3, 11</xref>
        ].
      </p>
    </sec>
    <sec id="sec-3">
      <title>Contributions</title>
      <p>This section discusses the two main contributions of this paper. First, we
propose Semi-Automated Role-Based Pattern Selection (SARBPS), a novel
semiautomated approach for selecting applicable software patterns in software
models. The approach exploits the relational nature of both software patterns and
software models to signi cantly reduce the time required to decide which
software patterns are applicable in a given software model. Second, we discuss how
relational learning can be used to further automate our approach and hence
reduce the amount of user interaction.
4.1</p>
      <sec id="sec-3-1">
        <title>Contribution 1: Semi-Automated Role-Based Pattern Selection</title>
        <p>We now discuss the three steps of the SARBPS approach in turn. The rst step
concerns representing the available software patterns as sets of primitives, where
each primitive ful lls one or more roles. SARBPS represents this information as
a knowledge base consisting of two classes of facts. The rst class is the class
of entity facts that enumerate the available patterns, primitives and roles. The
second class is the class of relation facts that de ne relations between patterns
and primitives on one hand and primitives and roles on the other hand. These
relations express which primitives each pattern comprises and which role(s) each
primitive ful lls. Roles are only meaningful if ful lled by at least one primitive.</p>
        <p>The second step involves annotating the components and interfaces of the
software model with additional information. A software developer employs the
requirements that the components and interfaces satisfy to assign one or multiple
roles, which describe their properties and characteristics. Roles indicate which
application-independent function the annotated element ful lls in a software
system. For example, a component that provides services to other components
can be assigned the ServiceProvider role. Only roles de ned in the knowledge
base constructed in the previous step can be assigned.</p>
        <p>The third step involves selecting applicable patterns by establishing a
mapping between the roles of the elements in the software model on one hand and
the roles of the available patterns on the other hand. For each of the available
patterns, SARBPS veri es whether it is applicable. A pattern is applicable if
and only if each of the software model's roles is ful lled by at least one of the
pattern's primitives. SARBPS achieves this by querying the knowledge base it
constructed in the rst step using the roles assigned during the second step.</p>
        <p>SARBPS uses two queries to retrieve all applicable patterns from the
knowledge base. The rst query returns for a given pattern and a given role which
of the pattern's primitives ful lls this role or fails when no primitive is found.
The second query returns a list of applicable patterns for a given set of roles
by iteratively calling the rst query for any possible combination of an available
pattern and a given role.</p>
        <p>Example 1. In order to illustrate our approach, we use the software model and
software pattern shown in Figures 1 and 2 respectively. Due to space constraints,
we only provide a high-level discussion in this paper.2 In the rst step, we
add the Client-Dispatcher-Server pattern and the three primitives this
pattern comprises, Client, Dispatcher and Server, to the knowledge base. We
also add the roles ServiceProvider and ServiceRequester, which the Server
and Client primitives ful ll respectively. In the second step, we assign the
ServiceProvider role to both the NewspaperService and ClientManagement
components, and the ServiceRequester role to the Client component. In the
third step, querying the knowledge base for applicable software patterns returns
the Client-Dispatcher-Server pattern.</p>
        <p>Although our semi-automated pattern selection approach saves signi cant
amounts of precious development time, manually assigning roles to components
and interfaces is still an error-prone and time-consuming task, especially for
large, real-world software systems. Therefore, we propose using relational
learning to automate this task and share some ideas on how to do this in what follows.
4.2</p>
      </sec>
      <sec id="sec-3-2">
        <title>Contribution 2: Towards Automated Role Annotations</title>
        <p>When annotating a component or an interface with one or multiple roles,
software developers leverage the descriptions of the requirements each component or
interface ful lls. These descriptions are mostly free text but they tend to have a
simple structure. For example, one of the requirements in our running example
states that a journalist must be able to add an article to the system. In a medical
system, a requirement could be that the medical sta must be able to add a new
patient le to the system. Although the descriptions of these requirements are
completely di erent, it is clear that they can be written as instances of the same
abstract pattern since they share a common structure.</p>
        <p>The missing building block is a convenient formal language for representing
software requirements. Once we have such a language, we can naturally model
requirements in a relational learning system and pose the assignment of roles to
components and interfaces as a collective classi cation task. We can then
represent components and interfaces as entities, and collaborations amongst these
components and interfaces as relations. The classi cation task boils down to
learning one or multiple roles for each component. The key idea is to leverage
the expert knowledge and previous role labeling e orts of software engineers,
who can possibly already assign roles to some of the components and interfaces.</p>
        <p>
          The kernel-based relational learning framework kLog [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ] is a suitable learning
system to perform this task. An important advantage of kLog is that the outcome
of its graphicalization phase, a ground entity-relationship model, is conceptually
very similar to a software model and hence easily interpretable by a software
engineer. Preliminary results on a toy example yield encouraging results.
2 A thorough discussion of the running example and a Prolog implementation are
available at https://people.cs.kuleuven.be/alexander.vandenberghe/sarbps.html.
We have introduced a novel semi-automated approach for selecting applicable
software patterns in software models, which makes developers to save signi cant
amounts of development time. Our approach relies on a concise relational
representation of both software patterns and software models, which allows reasoning
about them and including additional software patterns in a straightforward way.
        </p>
        <p>Our main research direction is further automating the approach using
relational learning techniques. The key challenge is designing a convenient formal
language for representing software requirements in a relational learning
framework. Furthermore, we aim to limit the number of proposed patterns by
incorporating each pattern's trade-o s and consequences.</p>
        <p>Acknowledgments. We thank Paolo Frasconi and Luc De Raedt for providing
access to the kLog implementation.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Buschmann</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meunier</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rohnert</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sommerlad</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stal</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>PatternOriented Software Architecture: A System of Patterns</article-title>
          . Wiley (
          <year>1996</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Correa</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Werner</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zaverucha</surname>
          </string-name>
          , G.:
          <article-title>Object Oriented Design Expertise Reuse: an Approach Based on Heuristics, Design Patterns and Anti-Patterns</article-title>
          . In: on Heuristics,
          <article-title>Design Patterns and Anti-patterns</article-title>
          ,
          <source>in Proceedings of the 6th International Conference on Software Reuse</source>
          . pp.
          <volume>336</volume>
          {
          <issue>352</issue>
          (
          <year>2000</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>DeMillo</surname>
            ,
            <given-names>R.A.</given-names>
          </string-name>
          ,
          <article-title>O utt, A</article-title>
          .J.:
          <article-title>Constraint-Based Automatic Test Data Generation</article-title>
          .
          <source>IEEE Trans. Softw. Eng</source>
          .
          <volume>17</volume>
          (
          <issue>9</issue>
          ),
          <volume>900</volume>
          {910 (Sep
          <year>1991</year>
          ), http://dx.doi.org/10.1109/32.92910
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Frasconi</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Costa</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>De Raedt</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>De Grave</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>kLog: A Language for Logical and Relational Learning with Kernels (</article-title>
          <year>2012</year>
          ), arXiv:
          <fpage>1205</fpage>
          .3981v3
        </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.: Design Patterns:
          <article-title>Elements of Reusable Object-Oriented Software</article-title>
          .
          <string-name>
            <surname>Addison-Wesley Professional</surname>
          </string-name>
          (
          <year>1994</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Hasheminejad</surname>
            ,
            <given-names>S.M.H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jalili</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Design Patterns Selection: An Automatic TwoPhase Method</article-title>
          .
          <source>The Journal of Systems and Software</source>
          <volume>85</volume>
          (
          <issue>2</issue>
          ),
          <volume>408</volume>
          {424 (Feb
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Hsueh</surname>
            ,
            <given-names>N.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kuo</surname>
            ,
            <given-names>J.Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lin</surname>
            ,
            <given-names>C.C.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Object-Oriented Design</surname>
          </string-name>
          :
          <article-title>A Goal-driven and Pattern-based Approach</article-title>
          .
          <source>Software and Systems Modeling</source>
          <volume>8</volume>
          (
          <issue>1</issue>
          ),
          <volume>67</volume>
          {
          <fpage>84</fpage>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8] Kamp meyer, H.,
          <string-name>
            <surname>Zschaler</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Finding the Pattern You Need: The Design Pattern Intent Ontology</article-title>
          .
          <source>In: Model Driven Engineering Languages and Systems</source>
          . pp.
          <volume>211</volume>
          {
          <fpage>225</fpage>
          . No. 4735
          <source>in Lecture Notes in Computer Science</source>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Kim</surname>
            ,
            <given-names>D.K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>El Khawand</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>An Approach to Precisely Specifying the Problem Domain of Design Patterns</article-title>
          .
          <source>Journal of Visual Languages &amp; Computing</source>
          <volume>18</volume>
          (
          <issue>6</issue>
          ),
          <volume>560</volume>
          {
          <fpage>591</fpage>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Van Landuyt</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          , Op de beeck, S.,
          <string-name>
            <surname>Truyen</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Verbaeten</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Building a Digital Publishing Platform Using AOSD</article-title>
          .
          <source>In: LNCS Transactions on Aspect-Oriented Software Development</source>
          . vol.
          <volume>9</volume>
          , pp.
          <volume>1</volume>
          {
          <issue>34</issue>
          (
          <year>December 2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Vanmali</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Last</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kandel</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Using a neural network in the software testing process</article-title>
          .
          <source>International Journal of Intelligent Systems</source>
          <volume>17</volume>
          (
          <issue>1</issue>
          ),
          <volume>45</volume>
          {
          <fpage>62</fpage>
          (
          <year>2002</year>
          ), http://dx.doi.org/10.1002/int.1002
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <surname>Zdun</surname>
            ,
            <given-names>U.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Avgeriou</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Modeling Architectural Patterns Using Architectural Primitives</article-title>
          .
          <source>ACM SIGPLAN Notices</source>
          <volume>40</volume>
          (
          <issue>10</issue>
          ),
          <volume>133</volume>
          {146 (Oct
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>