Professional Documents
Culture Documents
D i Metrics
Design
M ti
MeasuringDesignQuality
g
g
y
Why?
OnespecificationmanyDesigns!
One specification many Designs!
Subjective/Objective
Researchersdevelopingkeymetrics
h d l i k
i
Example
p
MetricforCoupling
SystemComplexity
System Complexity
Complexity=StructuralComplexity
+ Data Complexity
+DataComplexity
P i it ( t)
Priority(wt)
Reuse
Extendibility
Complexity
D i 1
Design1
D i 2
Design2
D i 3
Design3
Design Review Qs
DesignReviewQs
1.
2.
3
3.
4.
5.
6.
7.
Isthisdesignasolutiontotheproblem?
g
p
Isthedesignmodular,wellstructured?
I h d i
Isthedesignunderstandable
d
d bl
IsitPortable?
Isitreusable?
Isiteasytomodifyandextend?
Does it support ease of testing ?
Doesitsupporteaseoftesting?
Design Review Qs
DesignReviewQs
8. Doesthedesignmaximizeperformancewhere
appropriate?
9. Doesthedesignreusepatterns/code?
10.Arethealgorithmsappropriatecantheybe
p
improved?
11.Isthedesignwelldocumented?
12 Does the design cross reference the components
12.Doesthedesigncrossreferencethecomponents
anddatawiththerequirements?
13 D
13.Doesthedesignusetechniquesforfault
th d i
t h i
f f lt
tolerance?
Design Metrics
DesignMetrics
Design Metrics are useful in measuring the
complexity and goodness
goodness of a design
design.
A large number metrics have been proposed for
OO designs
Some of these have been validated
experimentally, others are mere proposals or
have received little or no validation
validation.
7
ExampleDesignMetrics
p
g
[Chidamber &Kemerer]
1. DesignComplexity
WeightedMethodsPerClass
W i ht d M th d P Cl
Sumofmethodcomplexities
2. DepthofInheritance
Maximum
MaximumLengthofthepathinthehierarchy
Length of the path in the hierarchy
fromtheclasstotherootoftheinheritancetree
3 NumberofChildren
3.
Number of Children
Numberofimmediatesubclasses
5. LackofCohesioninMethods
8. AveragenumberofParametersperoperation
9. Percentofpublic/protected
10 A
10.Amountofpublicaccesstodatamembers
t f bli
t d t
b
11.Fan_in
_ ((numberofclassescalling)
g)
12.Fan_out (numberofclassescalledby)
c
i
M
i
WMC
i 1
c
i
becomes harder.
Depth
D h off IInheritance
h i
(DIT) off class
l
C is
i the
h length
l
h off the
h
shortest path from the root of the inheritance tree to C.
In the case of multiple inheritance DIT is the maximum
Higher
Hi h DIT leads
l d to
t higher
hi h error-proneness.
13
is_client(x,y)=1iff arelationshipexists
b t
betweentheclientclassandtheserverclass.
th li t l
d th
l
0otherwise.
TCisthetotalnumberofrelationships
possible
CFis[0,1]with1meaninghighcoupling
Numberofchildren(NOC)
(
)
NOCisthenumberofimmediatesubclassesofC.
Higher values of NOC suggest reuse of the
Larger
L
NOC value
l is
i associated
i t d with
ith lower
l
probability
b bilit
Lackofcohesioninmethods(LCOM)
LetI1andI2denotesetsofinstancevariablesaccessedby
methodsM1andM2,respectively,inclassC.
h d
d
l
l
M1 and M2 are considered similar, or cohesive, if I1 and
pp multiple
p abstractions. Perhaps
p the class needs
support
to be partitioned into smaller and more cohesive classes.
NumberofOperationsOverridden(NOO)
AlargenumberforNOOindicatespossible
p
problemswiththedesign
g
Poorabstractionininheritancehierarchy
NumberofOperationsAdded(NOA)
Thenumberofoperationsaddedbyasubclass
Asoperationsareaddeditisfartherawayfrom
As operations are added it is farther away from
superclass
AsdepthincreasesNOAshoulddecrease
A d th i
NOA h ld d
SpecializationIndex(SI)
SI=[NOO*L]/M
[
] / _total
Listhelevelinclasshierarchy
M_total
M total isthetotalnumberofmethods
is the total number of methods
Highervaluesindicateclassinhierarchythatdoes
notconformtotheabstraction
f
h b
i
MethodInheritanceFactor(MIF)
Mi(Ci)isthenumberofmethodsinheritedand
) is the number of methods inherited and
notoverriddeninCi
Ma(C
( i)isthenumberofmethodsthatcanbe
)i h
b
f
h d h
b
invokedwithCi
MIFis[0,1]
MIFnear1meanslittlespecialization
MIF near 1 means little specialization
MIFnear0meanslargechange