of the simplified version of class diagrams is shown
in Figure 1 (a). As shown in the figure, it has the con-
cepts “Class”, “Operation” and “Attribute” and all of
them are defined as classes and these concepts have
associations representing logical relationships among
them. For instance, the concept “Class” has “At-
tribute”, so the association “has Attribute” between
“Class” and “Attribute” denotes this relationship.
We can embed metrics and their calculation meth-
ods into a meta model in the same way. More con-
cretely, metrics such as WMC (Weighted Methods per
Class), DIT (Depth of an Inheritance Tree) and NOC
(Number of Children) of CK metrics are defined as
classes having the attribute “value” in the meta model
as shown in the Figure 1 (b). The “value” has the met-
ric value and its calculation is defined as a constraint
written with OCL. For example, WMC is associated
with each class of a class diagram through the associ-
ation “has WMC” and the role names “owner WMC”
and “owned Operation” are employed to define the
value of WMC with OCL. Intuitively speaking, the
value of WMC is the number of the methods in a class
when we make weighted factors 1 and we take this
simple case. It can be defined as follows.
context WMC::value : Integer
derive: owner WMC.owned Operation -> size()
WMC and the other CK metrics are for a class not
for a class diagram. Thus we can use the maximum
number of WMCs in the class diagram or the average
value to represent the WMC for the whole of the class
diagram. In this example, which is used throughout
the paper, we take the sum total of WMCs for the class
diagram, and the attribute TNMvalue of Structural-
Complexity holds it as shown in Figure 1 (b). The
techniques of using OCL on a meta model to specify
metrics were also discussed in (Abreu, 2001; Saeki,
2003), and the various metrics for UML class dia-
grams can be found in (Genero et al., 2005).
3 GRAPH REWRITING SYSTEM
In Model Driven Development, one of the techni-
cally essential points is model transformation. Since
we use a class diagram to represent a meta model,
a model, i.e. an instance of the meta model can be
considered as a graph, whose nodes have types and
attributes, and whose edges have types, so called at-
tributed typed graph. Thus in this paper, model trans-
formation is defined as a graph rewriting system, and
graph rewriting rules dominate allowable transforma-
tions. In this section, we introduce a graph rewriting
system.
A graph rewriting system converts a graph into an-
other graph or a set of graphs following pre-defined
rewriting rules. There are several graph rewriting sys-
tems such as PROGRESS (Schurr, 1997) and AGG
(Taentzer et al., 2001). Since we should deal with
the attribute values attached to nodes in a graph, we
adopt the definition of the AGG system in this paper.
A graph consists of nodes and edges, and type names
can be associated with them. Nodes can have attribute
values depending on their type. The upper part of Fig-
ure 2 is a simple example of rewriting rules. A rule
consists of a left-hand and a right-hand side which
are separated with “::=”. The attribute values should
be able to be propagated in any direction, i.e. from
the left-hand side of “::=” to the right-hand side, the
opposite direction, as well as within the same side,
and this mechanism is similar to synthesized and in-
herited attributes of Attribute Grammar. In this sense,
the graph rewriting system that we use is an extended
version of AGG.
In figure 2, a rectangle box stands for a node of a
graph and it is separated into two parts with a hori-
zontal bar. Type name of a node appears in the upper
part of the horizontal bar, while the lower part con-
tains its attribute values. In the figure, the node of
“TypeA” in the left-hand graph has the attribute “val”
and its value is represented with the variable “x”. A
graph labeled with NAC (Negative Application Con-
dition) appearing in the left-hand controls the appli-
cation of the rule. If a graph includes the NAC graph,
the rule cannot be applied to it. In addition, we add
the conditions that are to be satisfied when the rule is
applied. In this example, we have two conditions, one
of which says that “val” of the node “1:TypeA” has to
be greater than 4 to apply this rewriting rule.
The lower part of Figure 2 illustrates graph rewrit-
ing. The part encircled with a dotted rectangular box
in the left-hand is replaced with the sub graph that is
derived from the right-hand of the rule. The attribute
values 5 and 2 are assigned to x and y respectively,
and those of the two instance nodes of “TypeD” re-
sult in 7 (x+y) and 3 (x-y). The attribute “val” of
“TypeD” node looks like an inherited attribute of At-
tribute Grammar because its value is calculated from
the attribute values of the left-hand side of the rule,
while “sval” of “TypeC” can be considered as a syn-
thesized attribute. The value of “sval” of the node
“TypeC” in the left-hand side is calculated from the
values in the right-hand side, and we get 8 (TypeD val
+ x = 3+5). Note that the value of “val” of “TypeA”
is 5, greater than 4, the value of “sval” is less than 10,
and none of nodes typed with “TypeD” appear, so the
rule is applicable. The other parts of the left-hand side
graph are not changed in this rewriting process.
METRICS FOR A MODEL DRIVEN DEVELOPMENT CONTEXT
15