paradigm independent software complexity metrics dr. zoltán porkoláb department of programming...
TRANSCRIPT
Paradigm IndependentParadigm IndependentSoftware Complexity MetricsSoftware Complexity Metrics
Dr. Dr. ZolZoltán Porkolábtán PorkolábDepartment of Programming Languages and CompilersDepartment of Programming Languages and Compilers
Eötvös Loránd University, Faculty of InformaticsEötvös Loránd University, Faculty of Informatics
e-mail: ge-mail: [email protected]@elte.hu
22SQI 2005.04.11. SQI 2005.04.11.
The structure of the presentationThe structure of the presentation
The role of software metricsThe role of software metrics
Metrics: an overviewMetrics: an overview
Object-oriented software metricsObject-oriented software metrics
Multiparadigm programmingMultiparadigm programming
The AV-graphThe AV-graph
ResultsResults
33SQI 2005.04.11. SQI 2005.04.11.
Role of software metricsRole of software metrics
Cost of the softwareCost of the software SpecificationSpecification DesignDesign ImplemeImplementationntation TesTesting & Bug-fixingting & Bug-fixing MaintenanceMaintenance
More than More than 70% 70% of cost is for testing and maintenanceof cost is for testing and maintenance (Zuse 1998)(Zuse 1998)
Software qualitySoftware quality
44SQI 2005.04.11. SQI 2005.04.11.
SoftSoftwareware metricsmetrics
Software metricsSoftware metrics:: Measuring the development process (process metrics)Measuring the development process (process metrics) Measuring the productMeasuring the product ( (product metricsproduct metrics))
Product metricsProduct metrics:: External metricsExternal metrics::
Reliability metricsReliability metricsFunctional metricsFunctional metricsEfficiency metricsEfficiency metrics
Internal product metricsInternal product metrics::SizeSize ComplexityComplexityStStyleyle
55SQI 2005.04.11. SQI 2005.04.11.
Product metricsProduct metrics
Size metricsSize metrics:: LOC, eLOCLOC, eLOC Ignore the semanticIgnore the semantic
Structural metricsStructural metrics::
McCabe 1976McCabe 1976 MotivationMotivation: : predict testing effortspredict testing efforts For structured programsFor structured programs: V(G) = p + 1: V(G) = p + 1
HowattHowatt and and Baker 1989 Baker 1989 MotivationMotivation: : involve nesting levelinvolve nesting level SN(G) = |N|+ND(G)SN(G) = |N|+ND(G)
66SQI 2005.04.11. SQI 2005.04.11.
Object-oriented metrics in theoryObject-oriented metrics in theory
Chidamber-Kemerer (1994)Chidamber-Kemerer (1994) OO metrics suite: OO metrics suite: WMC (Weighted Methods per Class)WMC (Weighted Methods per Class) DIT (Depth of Inheritance Tree, DIT)DIT (Depth of Inheritance Tree, DIT) NOC (Number of ChildNOC (Number of Child Classes Classes)) CBO (Coupling Between Object Classes)CBO (Coupling Between Object Classes) fan-in fan-in
and fan outand fan out RFC (Response for Class)RFC (Response for Class) LCOM (Lack of Cohesion in Methods)LCOM (Lack of Cohesion in Methods)
Chidamber - KemererChidamber - Kemerer
Henderson - SellersHenderson - Sellers
77SQI 2005.04.11. SQI 2005.04.11.
Object-Oriented metrics in practiceObject-Oriented metrics in practice
EclipseEclipse ( (www.eclipse.orgwww.eclipse.org))
McCabe McCabe cyclomatic complexitycyclomatic complexity Efferent couplingEfferent coupling ( (≠ fan out!)≠ fan out!) Lack of CohesionLack of Cohesion LOC (Lines of Code)LOC (Lines of Code) Number of Fields in ClassesNumber of Fields in Classes Nesting DepthNesting Depth Number of Number of Method Method ParametersParameters Number of StatementsNumber of Statements Weighted Methods per ClassWeighted Methods per Class
88SQI 2005.04.11. SQI 2005.04.11.
Software paradigmSoftware paradigm
Evolution of Software paradigmEvolution of Software paradigm Structured programmingStructured programming Object-oriented programmingObject-oriented programming
Classes, inheritance, virtual functionClasses, inheritance, virtual function Generative programming Generative programming
Aspect-Oriented (Kitzales 1994)Aspect-Oriented (Kitzales 1994)
Intentional (Simonyi 1995)Intentional (Simonyi 1995)
Template metaprogramming (Veldhuizen 1994)Template metaprogramming (Veldhuizen 1994)
Multiparadigm programming (Coplien 1998)Multiparadigm programming (Coplien 1998) Simultaneous usage of paradigmsSimultaneous usage of paradigms
99SQI 2005.04.11. SQI 2005.04.11.
Paradigm-independent Software MetricsParadigm-independent Software Metrics
Applicable for programs written in different Applicable for programs written in different paradigms or paradigms or in in mixed-paradigm environment mixed-paradigm environment
Based on general programming language features which Based on general programming language features which are paradigm- and language-independent.are paradigm- and language-independent.The paradigm-dependent attributes are derived fromThe paradigm-dependent attributes are derived fromthese features.these features.
1010SQI 2005.04.11. SQI 2005.04.11.
ComponentsComponents
Control Structure of ProgramControl Structure of Program Most of the programs share the same control Most of the programs share the same control
statementsstatements
Complexity of Data TypesComplexity of Data Types Reflects the complexity of data types used (like Reflects the complexity of data types used (like
classes)classes)
Complexity of Data AccessComplexity of Data Access Connection between control structure and data Connection between control structure and data
Direction of data flowDirection of data flowNesting depthNesting depth
1111SQI 2005.04.11. SQI 2005.04.11.
AV-graphAV-graph
smain
P1
tmain
b
P4
ac
d1
d3d4
d2
data node
output node
input node
1212SQI 2005.04.11. SQI 2005.04.11.
class date{public: void set_next_month() { if ( month == 12 ) { month = 1; year = year + 1; } else { month = month + 1; } } void set_next_day() { if ( month == 1 || month == 3 || ... || month == 12 ) if ( day == 31 ) set_next_month(); else day = day + 1; else if ( day == 30 ) set_next_month(); else day = day + 1; }private:
int year, month, day;};
Complexity of ClassComplexity of Class
sset_next_month
P1
tsnm
b
a c
sset_next_day
P2
tsnm
e
P3
gf
P4d1
d3
d2
1313SQI 2005.04.11. SQI 2005.04.11.
Our Our Measuring toolMeasuring tool
Supported lSupported languageanguagess Java 1.3Java 1.3 Java 1.4Java 1.4 (assert) (assert) Java 5 (generics)Java 5 (generics)
ImplementationImplementation sstandalonetandalone application and application and Eclipse Plug-inEclipse Plug-in
OuputOuput CSVCSV XMLXML
1414SQI 2005.04.11. SQI 2005.04.11.
Test DataTest Data
Java Standard Library 1.4.2Java Standard Library 1.4.2 367367.000.000 eLOC eLOC
jBOSS 3.2.3jBOSS 3.2.3 300300.000.000 eLOC eLOC
Omg.org.CORBAOmg.org.CORBA 55.000.000 eLOC eLOC
The measure tool (with mostly generated parser)The measure tool (with mostly generated parser) 77.000.000 eLOC eLOC
Eclipse 3.0M6Eclipse 3.0M6 900900.000.000 eLOCeLOC
17.000 17.000 cclasslass – more than 1.5 million lines – more than 1.5 million lines
1515SQI 2005.04.11. SQI 2005.04.11.
ResultsResults
No statistical correlation between the OO and multi No statistical correlation between the OO and multi paradigm metrics:paradigm metrics: OO metrics only measure the big pictureOO metrics only measure the big picture MPM consider more properties: higher densityMPM consider more properties: higher density The structural complexity of methods are extremely The structural complexity of methods are extremely
increase the overall complexity.increase the overall complexity.