Agile Code Quality Metrics
Gil Nahmias, CSP
Summary for Experts
Metrics Tools
– WTF/Minute - „Metrics‟ eclipse
– Abstractness vs. Instability plugin
– Cyclomatic complexity - Ndepend
– Test cases/Class - SourceMonitor
– Defect Density - Klocwork
– Fan in, Fan out
– Code coverage, Test
coverage
disclaimer
“Metrics are a carving knife when what you
really need is a scalpel. Metrics can tell you
something is wrong, but they can't give you
much guidance about the precise cause.
In the case of clean code, the cause is
discipline and professionalism”...”Fixing
that problem is a matter of instilling
pride of workmanship into the team”
-- Uncle Bob
Note before we start
What are we
trying to
understand
What we
actually
measure
How does it
make people
behave
Note before we start
What are we
trying to
understand
What we
actually
measure
How does it
make people
behave
Note before we start
What are we
trying to
understand
What we
actually
measure
How does it
make people
behave
WTF/Minute – in code review
Abstractness vs. instability
Software quality
Defect Density: number of defects per lines
of code
Unit test density: number of unit test cases
per feature or class.
MINIMUM +ve (actual = expected)
4 -ve (actual != expected)
stress
integration
completeness
Code coverage: percentage of automatically
tested code
Test coverage: percentage of automatically
tested business scenarios
Tests
Business Code
complexity
Fan-in: per type is the number of types that
depends directly on it. [a.k.a. Afferent Coupling]
Fan-out: per type is the number of types it
directly depends on. [a.k.a. Efferent Coupling]
Cyclomatic complexity: number of decisions
that can be taken in a procedure
[can be measured per class/feature]
contact me for more
gil@agilesparks.com
@gilnahmias
myagile.co.il