This set of slides was used for the tutorial given by Tudor Girba, Michele Lanza and Radu Marinescu at International Conference on Software Engineering (ICSE) 2008.
Take control of your SAP testing with UiPath Test Suite
Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
1. Pragmatic Design Quality Assessment
Tudor Gîrba
University of Bern, Switzerland
Michele Lanza
University of Lugano, Switzerland
Radu Marinescu
Politehnica University of Timisoara, Romania
20. fo
rw
ar
d
en
gin
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
21. What is the current state?
fo
rw
ar
What should we do?
d
en
Where to start?
gin
ee
How to proceed?
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
22. fo
rw
g
rin
ar
ee
d
gin
en
gin
en
ee
se
rin
erv
g
re
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
23. Reverse engineering is analyzing a subject system to:
identify components and their relationships, and
create more abstract representations.
Chikofky & Cross, 90
24. { {
{ {
}
}
}
} { }
A large system contains lots of details.
25. ity?
its qual
ju dge
How to { {
{ {
}
}
}
} { }
A large system contains lots of details.
34. Examples of size metrics
NOM - number of methods
NOA - number of attributes
LOC - number of lines of code
NOS - number of statements
NOC - number of children
Lorenz, Kidd, 1994
Chidamber, Kemerer, 1994
35. McCabe cyclomatic complexity (CYCLO) counts
the number of independent paths through the code of a
function.
McCabe, 1977
it reveals the minimum number of tests to write
interpretation can’t directly lead to improvement action
36. Weighted Method Count (WMC) sums up the
complexity of class’ methods (measured by the metric
of your choice; usually CYCLO).
Chidamber, Kemerer, 1994
it is configurable, thus adaptable to our precise needs
interpretation can’t directly lead to improvement action
37. Depth of Inheritance Tree (DIT) is the (maximum)
depth level of a class in a class hierarchy.
Chidamber, Kemerer, 1994
inheritance is measured
only the potential and not the real impact is quantified
38. Coupling between objects (CBO) shows the number
of classes from which methods or attributes are used.
Chidamber, Kemerer, 1994
it takes into account real dependencies not just declared ones
no differentiation of types and/or intensity of coupling
39. Tight Class Cohesion (TCC) counts the relative
number of method-pairs that access attributes of the
class in common.
Bieman, Kang, 1995
TCC = 2 / 10 = 0.2
interpretation can lead to improvement action
ratio values allow comparison between systems
45. Problem 1: metrics granularity
?
capture symptoms, not causes of problems
in isolation,
they don’t lead to improvement solutions
46. Problem 1: metrics granularity
?
capture symptoms, not causes of problems
in isolation,
they don’t lead to improvement solutions
Problem 2: implicit mapping
we don’t reason in terms of metrics,
but in terms of design principles
47. 2 big obstacles in using metrics:
Thresholds make metrics hard to interpret
Granularity make metrics hard to use in isolation
49. fo
rw
ar
d
en
gin
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
50. fo
rw
How do I understand code?
ar
d
en
gin
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
51. fo
rw
How do I understand code?
ar
d
How do I improve code?
en
gin
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
52. fo
rw
How do I understand code?
ar
d
How do I improve code?
en
gin
How do I improve myself?
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
53. etr ics!
w ith m
o do
i ng t
tn oth
I wan
fo
rw
How do I understand code?
ar
d
How do I improve code?
en
gin
How do I improve myself?
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
54. How to get an initial understanding of a system?
55. Metric Value
LOC 35175
NOM 3618
NOC 384
CYCLO 5579
NOP 19
CALLS 15128
FANOUT 8590
AHH 0.12
ANDC 0.31
56. Metric Value
LOC 35175
NOM 3618
NOC 384
CYCLO 5579
NOP 19
CALLS 15128
FANOUT 8590
AHH 0.12
ANDC 0.31
57. Metric Value
LOC 35175
NOM 3618
NOC 384
CYCLO 5579
NOP 19
CALLS 15128
FANOUT 8590
ha t?
ww
AHH
An d no 0.12
ANDC 0.31
66. The Overview Pyramid provides a metrics
overview. Lanza, Marinescu 2006
ANDC 0.31
AHH 0.12
20.21 NOP 19
9.42 NOC 384
9.72 NOM 3618 NOM 418
0.15 LOC 35175 15128 CALLS 0.56
CYCLO 5579 8590 FANOUT
close to high close to average close to low
67. The Overview Pyramid provides a metrics
overview. Lanza, Marinescu 2006
close to high close to average close to low
68. fo
rw
How do I understand code?
ar
d
How do I improve code?
en
gin
How do I improve myself?
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
69. etr ics!
w ith m
o do
i ng t
oth
nt n
I wa
fo
rw
How do I understand code?
ar
d
How do I improve code?
en
gin
How do I improve myself?
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
77. God Classes tend to centralize the intelligence of the
system, to do everything and to use data from small
data-classes.
Riel, 1996
78. God Classes tend
to centralize the intelligence of the system,
to do everything and
to use data from small data-classes.
79. God Classes
centralize the intelligence of the system,
do everything and
use data from small data-classes.
80. God Classes
are complex,
are not cohesive,
access external data.
81. God Classes
are complex,
are not cohesive,
access external data.
sing
uer ies u
to q s
s in ator
etric per
se m ical o
Co mpo log
82. Detection Strategies are metric-based queries to
detect design flaws. Lanza, Marinescu 2006
Rule 1
METRIC 1 > Threshold 1
AND Quality problem
Rule 2
METRIC 2 < Threshold 2
83. Shotgun
Surgery has
uses is
has (partial) Feature Data
Envy uses Class
is partially
God has
Intensive Class
Coupling Brain has
has
Method
Extensive Brain has Significant
Coupling Class Duplication
has
is
is
has
Refused
is Tradition
Parent
Breaker
Bequest
has (subclass)
Futile
Hierarchy Lanza, Marinescu 2006
Identity Collaboration Classification
Disharmonies Disharmonies Disharmonies
84. A God Class centralizes too much intelligence in
the system. Lanza, Marinescu 2006
Class uses directly more than a
few attributes of other classes
ATFD > FEW
Functional complexity of the
class is very high
AND GodClass
WMC ! VERY HIGH
Class cohesion is low
TCC < ONE THIRD
85. An Envious Method is more interested in data
from a handful of classes. Lanza, Marinescu 2006
Method uses directly more than
a few attributes of other classes
ATFD > FEW
Method uses far more attributes
of other classes than its own
AND Feature Envy
LAA < ONE THIRD
The used quot;foreignquot; attributes
belong to very few other classes
FDP ! FEW
86. Data Classes are dumb data holders.
Lanza, Marinescu 2006
Interface of class reveals data
rather than offering services
WOC < ONE THIRD
AND Data Class
Class reveals many attributes and is
not complex
87. Data Classes are dumb data holders.
Lanza, Marinescu 2006
More than a few public
data
NOAP + NOAM > FEW
AND
Complexity of class is not
high
WMC < HIGH
Class reveals many
OR attributes and is not
Class has many public complex
data
NOAP + NOAM > MANY
AND
Complexity of class is not
very high
WMC < VERY HIGH
88. fo
rw
ar
d
en
gin
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
89. fo
rw
How do I understand code?
ar
d
How do I improve code?
en
gin
How do I improve myself?
ee
rin
g
{ {
{ { { {
} { {
}
} actual development } }
} { } } }
116. We do not see with our eyes, but with our brain.
Our brain works like a computer, with 3 types of memory
Iconic memory, the visual sensory register
Short-term memory, the working memory
Long-term memory
Sensation Perception
(Physical Process) (Cognitive Process)
Stimulus Sensory Organ Perceptual Organ
Brain
Iconic Memory - Short-term Memory - Long-term Memory
118. Iconic Short-term
memory memory
< 1 second
very fast
automatic
subconscious
preattentive
119. Iconic Short-term
memory memory
< 1 second couple of seconds
very fast 3-9 chunks
automatic
subconscious
preattentive
120. Categorizing Preattentive Attributes
Category Form Color Spatial Motion Motion
Orientation Hue 2D position Flicker
Line length Intensity Direction
Line width
Size
Attribute
Shape
Curvature
Added marks
Enclosure
134. Software visualization is
the use of the crafts of typography, graphic design, animation,
and cinematography with modern human-computer interaction
and computer graphics technology to facilitate both the human
understanding and effective use of computer software.
Price, Becker, Small
183. ENOM LENOM EENOM
balanced changer 7 3.5 3.25
late changer 7 5.75 1.37
3 1 2
dead stable 0 0 0
early changer 7 1.25 5.25
184. ENOM LENOM EENOM
balanced changer 7 3.5 3.25
late changer 7 5.75 1.37
ed.
measur3 1 2
be
ry can
H isto
dead stable 0 0 0
early changer 7 1.25 5.25
185. History can be measured in many ways.
Evolution Number of Methods
Stability Number of Lines of Code
Historical Max of Cyclomatic Complexity
Growth Trend Number of Modules
... ...
186. The recently changed parts are likely to change in the
near future.
Common wisdom
187. The recently changed parts are likely to change in the
near future.
ally?
Common wisdom
re
re they
A
195. past future
YesterdayWeatherHit(present):
past:=histories.topLENOM(start, present)
future:=histories.topEENOM(present, end)
past.intersectWith(future).notEmpty()
present
196. past future
YesterdayWeatherHit(present):
past:=histories.topLENOM(start, present)
future:=histories.topEENOM(present, end)
past.intersectWith(future).notEmpty()
present
prediction hit
197. Yesterday’s Weather shows the localization of changed in
time. Girba etal, 2004
hit hit hit
YW = 3 / 8 = 37%
hit hit hit hit hit hit hit
YW = 7 / 8 = 87%
198. A God Class centralizes too much intelligence in
the system.
Class uses directly more than a
few attributes of other classes
ATFD > FEW
Functional complexity of the
class is very high
AND GodClass
WMC ! VERY HIGH
Class cohesion is low
TCC < ONE THIRD
199. A God Class centralizes too much intelligence in
the system.
Class uses directly more than a
few attributes of other classes
ATFD > FEW
tab le?
f it is s
wh
Functional complexity of the at i
ut,
class is very high
B AND GodClass
WMC ! VERY HIGH
Class cohesion is low
TCC < ONE THIRD
200. History-based Detection Strategies take evolution
into account. Ratiu etal, 2004
God Class
in the last version
isGodClass(last)
AND Harmless God Class
Stable throughout
the history
Stability > 90%
201. What happens with inheritance?
A A A A A
B C B C B C B B
D D D E
ver .1 ver. 2 ver. 3 ver. 4 ver. 5
A is persistent, B is stable, C was removed, E is newborn ...
202. Hierarchy Evolution encapsulates time.
Girba etal, 2005
A
changed
methods
changed
age
lines
C B
Removed
Removed
D E
A is persistent, B is stable, C was removed, E is newborn ...
222. Pragmatic Design Quality Assessment
Tudor Gîrba
University of Bern, Switzerland
Michele Lanza
University of Lugano, Switzerland
Radu Marinescu
Politehnica University of Timisoara, Romania
223. Tudor Gîrba, Michele Lanza, Radu Marinescu
http://creativecommons.org/licenses/by/3.0/