| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| <link rel="stylesheet" type="text/css" href="../css/ot.css" /> |
| <link rel="stylesheet" type="text/css" href="../css/otjld.css" /> |
| <title>OT/J Language Definition v1.3.1</title> |
| </head> |
| <body class="otdt"> |
| <div id="content"> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a id="top"></a><a href="s2.1.2.a.html" rel="prev"><< §2.1.2.(a) No role of the same team</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"><a href="s2.1.2.c.html" rel="next">§2.1.2.(c) Base class decapsulation >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.1.html" rel="section">§2.1 playedBy relation</a> > <a class="nav" href="s2.1.2.html" rel="section">§2.1.2 Legal base classes</a></div> |
| <div class="subsect depth4" id="s2.1.2.b"> |
| <h4 class="subsect">§2.1.2.(b) <span class="title">Cycles</span><a class="img" href="s2.1.2.b.html" title="PermaLink to (b) Cycles"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>The base class mentioned after <code>playedBy</code> should normally not be |
| an enclosing type (at any depth) of the role class being defined. |
| <br /> |
| This rule discourages the creation of cycles where the base instance of |
| a given role <code>R</code> contains roles of the same type <code>R</code>. |
| <br /> |
| More generally this concerns any sequence of classes <code>C<sub>1</sub>, C<sub>2</sub>, .. C<sub>n</sub></code> |
| were each <code>C<sub>i+1</sub></code> is either a member or the base class of |
| <code>C<sub>i</sub></code> and <code>C<sub>n</sub> = C<sub>1</sub></code>. |
| <br /> |
| Such structures may be difficult to understand and have certain restrictions regarding |
| callout (<a href="s3.1.a.html" title="§3.1.(a) Prerequisite: Class binding" |
| class="sect">§3.1.(a)</a>) and base constructor calls (<a href="s2.4.2.html" |
| title="§2.4.2 Role creation via a regular constructor" |
| class="sect">§2.4.2</a>). |
| It is furthermore recommended to equip all roles that are played by an enclosing class with a guard predicate (<a href="s5.4.html" title="§5.4 Guard predicates" class="sect">§5.4</a>) like this: |
| |
| </p> |
| <div class="listing plain"><pre><em>base</em><em> when</em> (MyTeam.this == <em>base</em>)</pre></div> |
| <p> |
| This will avoid that the role adapts other instances of the enclosing class which are not the enclosing instance. |
| |
| </p> |
| <p> |
| It is prohibited to bind a role class to its own inner class. |
| |
| </p> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a href="s2.1.2.a.html" rel="prev"><< §2.1.2.(a) No role of the same team</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"><a href="s2.1.2.c.html" rel="next">§2.1.2.(c) Base class decapsulation >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.1.html" rel="section">§2.1 playedBy relation</a> > <a class="nav" href="s2.1.2.html" rel="section">§2.1.2 Legal base classes</a></div> |
| </div> |
| <div id="footer"> |
| <hr /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer" |
| shape="rect"><img src="../images/valid-css2-blue.png" alt="Valid CSS!" height="31" width="88" /></a><a class="w3c img" href="http://validator.w3.org/check?uri=referer" shape="rect"><img src="../images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" |
| width="88" /></a><address>© Stephan Herrmann, Christine Hundt, Marco Mosconi</address> |
| OT/J version 1.3.1 — last modified: 2013-05-28 |
| </div> |
| </body> |
| </html> |