multiplicity conformance. This rule checks if two
elements involved in a substitution are both single
valued (upper multiplicity = 1) or both multivalued
(upper multiplicity > 1) and, for the second case,
both elements must have the same kind of ordering
(ordered/not-ordered).
The single/multiple valued is important for
computability because code that uses a multivalued
element does it through flow control structures and
operations that act upon collections of values (e.g.:
foreach x in obj.feature, obj.feature.size(), etc.),
while code using a single-valued element accesses it
directly. Therefore, a computable piece of code that
uses a single-valued element, becomes non-
computable if that element is replaced by a
multivalued one, and vice versa.
For multivalued elements, the ordered/not-
ordered nature may also impact computability. On
ordered elements one can apply operations that
assume an ordering of values, such as the OCL
operations first (), last (), and at ().Calls to such
operations will not compute if the ordered element is
replaced by a non-ordered one. Similarly, some
operations on non-ordered elements are not
applicable to ordered ones, e.g. the OCL operation
intersection ().
Strictly, computability would be compromised
only if the code of the template includes any of these
operations depending on ordered/not-ordered. This
aspect opens the possibility for establishing two
levels of conformity enforcement – say, strict and
flexible – a subject for future discussion.
It is also worth explaining that the reason why
this conformance criteria doesn’t take into account
concrete values of multiplicity, other than 1 and *, is
because it is considered a matter of semantic
equivalence, not a requisite for computability. Albeit
a legitimate concern, it is also postponed for future
discussion.
4.3 Contents Conformance
This conformance criterion applies to template
parameters that expose namespaces – namely:
classes, associations, operations, packages, and all
other constructs subclassifying Namespace in the
UML metamodel (see (OMG 2012)). This rule is
meant to certify that a substituting element (e.g., a
class) contains substituting elements (e.g., member
attributes) to all members that the template assumes
there are in the parametered element. For instance, if
a template has a parameter-class and uses the
attributes a1 and a2 of that class, then every
substitute must also be a class with attributes a1 and
a2 or some substitutes for these. For instance,
recalling the template shown in Figure 3, the class
substituting Item must have an attribute Name.
The definition of this criterion requires the
definition of another concept: Implicit Substitution.
In the context of a bind, an element implicitly
substitutes another if they are homonymous,
functionally conform and the namespace of the
former substitutes the namespace of the latter. In this
definition, “homonymous” refers to having the same
proper name, i.e., the elements have the same
identification within the corresponding namespaces.
For example, attributes Item::Name and
Person::Name are properly homonymous. The same
is true between the operations Item::setName
(String) and Person::setName (String). But not
between ::setName (String) and ::setName (String,
String), because in UML an operation is identified
by its name and signature. If two properly
homonymous elements e
T
and e
~
are also
conformant in type, multiplicity, etc. (note the
recursive definition) and the namespace of e
T
is
substituted by the namespace of e
~
, then e
T
is
substituted implicitly by e
~
. Notice that this
definition is assuming that, even if the bind under
consideration doesn’t include an explicit substitution
of e
T
by e
~
, such substitution will be made. For
example, recalling Figure 5, previous statement
implies that, even though the modeller doesn’t
specify the substitution of Item::Name by
Concept::Name, such substitution is done. Thus, the
concept of implicit substitution is an assumption
regarding the semantics of the Bind relationship,
regarding an aspect that UML’s official
documentation omits. Such assumption certainly
deserves further discussion, yet postponed for
another text. For the current purpose, implicit
substitutions are assumed, just on the basis that the
automatic substitution of an element by another with
the same characteristics and name (or signature) is a
reasonable option.
Thus, Contents Conformance is defined as: in the
context of a template binding, namespace NS
~
conforms in contents to a namespace NS
T
if every
element in NS
T
referenced by the template is
substituted, explicitly or implicitly, by elements in
NS
~
.
This rule would detect problems such as the one
previously shown in Figure 7. The substitution of
Item by Document would be refused because those
elements do not have conforming contents, since
Item::Name is neither substituted nor homonymous
of any attribute in Document (Figure 11).
MODELSWARD2015-3rdInternationalConferenceonModel-DrivenEngineeringandSoftwareDevelopment
128