Title: A GraphBased Metamodel for ObjectOriented Software Metrics
1A Graph-Based Metamodelfor Object-OrientedSoftwa
re Metrics
- Tom Mens (tom.mens_at_vub.ac.be)
- Postdoctoral Fellow Fund for Scientific
Research (Flanders) - Vrije Universiteit Brussel, Belgium
2Goal
- use graphs as an underlying formalism/representati
on to - define a formal framework for OO metrics
independent of - the programming language (e.g., Smalltalk, Java,
or C) - the life-cycle phase (e.g., design or
implementation) - identify a minimal set of primitive functions to
cover an as wide variety of OO metrics as
possible - implement open and customisable metrics tools
- easy to add new OO metrics
- easy to incorporate new language features
- easy to use and customise at different levels of
abstraction
3Approach
- top-down
- improve existing metrics tools
- CodeCrawler
- SoulMetrics
- bottom-up
- develop generic graph-based formalism
- validate
- on a variety of OO metrics suites
- on a significant number of different programs
4Tool support CodeCrawler
- a language independent reverse engineering tool
- combines metrics and software visualization
- based on the FAMIX language-independent metamodel
- implemented in VisualWorks 3.0 Smalltalk
- runs on every major platform
5Tool support CodeCrawler
6Tool support CodeCrawler
7Tool support SoulMetrics
- a generic logic-programming-based metrics tool
- defined in SOUL, a logic meta-programming
environment - on top of Smalltalk VisualWorks 7
- a collection of logic predicates
- fully integrated in the Smalltalk GUI (browser)
- runs on every major platform
8Tool support SoulMetrics
9Tool support SoulMetrics
10Tool support SoulMetrics
11Represent software as graphs
- Directed attributed multi-graphs
12Primitive graph functions
- pred Node ? PF(Node) predecessor nodes
- succ Node ? PF(Node) successor nodes
- fanIn Node ? PF(Edge) incoming edges
- fanOut Node ? PF(Edge) outgoing edges
- path Node ? Node ? PF(Edge) edge paths
- iterative versions predi, pred, pred, succi,
succ, succ
13Primitive graph functions
14Primitive graph functions
15Primitive graph functions
16Primitive graph functions
17Primitive graph functions
18Qualified graph functions
- pred Node?NodeConstraint?EdgeConstraint ?
PF(Node) - idem for predi, pred, pred, succi, succ, succ
- fanIn Node?EdgeConstraint ? PF(Edge)
- idem for fanOut
- path Node?Node?NodeConstraint?EdgeConstraint ?
PF(Edge) - begin is defined in terms of pred
- calculates all nodes that have no predecessors
- end is defined in terms of succ
- calculates all nodes that have no successors
19Qualified graph functions
20Qualified graph functions
- pred(c,isClassNode,isUsesEdge)
21Object-oriented inheritance metrics
- Let n?Node such that isClassNode(n)
- subclasses(n) pred(n,isClassNode,isInheritsEdge
) - descendants(n) pred(n,isClassNode,isInheritsEd
ge) - leafClasses(n) start(n,isClassNode,isInheritsEd
ge) - inheritanceToRoot(n) ? path(n,m,isClassNode,is
InheritsEdge) - m?end(n,isClassNode,isInheritsEdge
) - NOS(n) subclasses(n)
- NOD(n) descendants(n)
- NOL(n) leafClasses(n)
- DIT(n) average(inheritanceToRoot(n),map(length))
22Object-oriented inheritance metrics
23Object-oriented inheritance metrics
24Object-oriented inheritance metrics
25Object-oriented inheritance metrics
- inheritanceToRoot(c2) DIT(c2)2
26Ratio Metrics
- MethodHidingFactor(n)
- 1 Ratio(succ,isMethodNode,isPublicNode,isConta
insEdge)(n) - 1- succ(n,isMethodNode?isPublicNode,isContainsE
dge) - succ(n,isMethodNode,isContainsEd
ge) - AbstractSubclassRatio(n)
- 1 Ratio(pred,isClassNode,isAbstractNode,isInhe
ritsEdge)(n) - LeafclassRatio(n)
- 1 Ratio(pred,isClassNode,isInheritanceLeaf,is
InheritsEdge)(n)