SlideShare a Scribd company logo
1 of 21
Download to read offline
Understanding
Software Metrics
Tushar Sharma
Tushar Sharma
Agenda
OO metrics
and their
classification
Using
metrics in
practice
Advanced
stuff…
Metrics:
What and
why
Software Metrics - What & Why?
A software metric is a measure of some property of a
software system.
Why?
“Measurement is the first step that leads to control and
eventually to improvement. If you can’t measure
something, you can’t understand it.”
(by James Harrington)
Tushar Sharma
Object-oriented Metrics
Size
Complexity
Cohesion &
Coupling
Project Namespace Type Method
LOC
NOC
NON
LOC
NOC
LOC
NOM
NOF
DIT
NC
RFC
LOC
NP
WMC CC
LCOM
CBO
Fan-in/
Fan-out
Tushar Sharma
OO Metrics - Size
• Large entities make the comprehension difficult.
• Large entities indicate presence of various smells.
LOC Lines Of Code
NON Number Of Namespaces
NOC Number Of Classes
NOM Number Of Methods
NOF Number Of Fields
Tushar Sharma
OO Metrics - Size
The response set of a class is a set
of methods that can potentially be
executed in response to a message
received by an object of that
class.
• Larger the number of methods that can be invoked, the greater the
complexity of the class.
• If a large number of methods can be invoked in response to a
message, the testing and debugging of the class becomes more
complicated .
RFC Response For Class
Tushar Sharma
OO Metrics - Size (Hierarchy)
• Deep inheritance trees make
the comprehension difficult.
• The deeper a class is in the
hierarchy, the greater the
number of methods it is likely
to inherit, making it more
complex to predict its
behaviour.
• Again, wide inheritance trees make the comprehension
difficult.
• A wide hierarchy indicates missing intermediate inheritance
level that in turn may lead to code duplication.
DIT Depth of Inheritance Tree
NC Number of Children
Tushar Sharma
OO Metrics - Cohesion and Coupling
Consider a class C with n methods M1, M2..., Mn. Let {Ij} = set of
instance variables used by method Mi.
There are n such sets I1 ,…, In
• P = {(Ii, Ij) | (Ii ∩ Ij ) = ∅}
• Q = {(Ii, Ij) | (Ii ∩ Ij ) ≠ ∅}
LCOM = |P| - |Q|, if |P| > |Q|
= 0, otherwise
• High LCOM indicate the violation of the Single Responsibility
Principle.
LCOM Lack of Cohesion
Of Methods
Tushar Sharma
OO Metrics - Cohesion and Coupling
CBO for a class is a
count of the number
of other classes to
which it is coupled.
• Excessive coupling between object classes is detrimental to
modular design and prevents reuse. The more independent a
class is, the easier it is to reuse it in another application.
• A measure of coupling is useful to determine how complex the
testing of various parts of a design are likely to be. The higher
the inter-object class coupling, the more rigorous the testing
needs to be.
CBO Coupling Between Object classes
Tushar Sharma
OO Metrics - Complexity
• CC - It is a quantitative measure of the number
of linearly independent paths through a
program's source code.
• WMC – Sum of CC of each method in the class
• The number of methods and the complexity of methods involved
is a predictor of how much time and effort is required to develop
and maintain the class.
CC Cyclomatic Complexity
WMC Weighted Methods per Class
Tushar Sharma
Using metrics in practice - tools
C/C++
CppDepend
Infusion
Source Monitor
C#
Designite
NDepend
Java
Infusion
Source Monitor
Tushar Sharma
Using metrics in practice
• There is no one single widely accepted standard for metrics
thresholds.
• There are some guidelines and rules of thumb!
Metric - Recommended Threshold
LOC (Method) - 50
LOC (File) - 500
NOC - 9
DIT - 5
LCOM - 0.80
NOM - 30
CBO - 6
CC - 10
WMC - 100
% Duplication - 4%
Metric thresholds
Tushar Sharma
Using metrics in practice
What if you want to perform an analysis with customized metric
thresholds
http://www.designite-tools.com
Tushar Sharma
What can be done with metrics data
• Indicator of “Structural Quality”
• Refactoring candidates
LackofCohesion
0
500
1000
1500
2000
2500
3000
3500
createFaxFaxSender
PrintSender
SASC
ontext
SASFoldableTableC
ellW
idget
SASFoldableTable
SASSortFoldableTable
SASFoldableD
ynam
icC
olum
nScrollTable
SASFoldableD
ynam
icTable
SASSortTable
SASLaterality
SASProcedureTree
SASSiriusLPA
SASProcedureTreeU
serO
bject
PortalApplication
PortalR
ISApplicationR
adiologist
SASServerH
essianProxy
C
lientC
onfig
U
serPreferences
SASC
riteria
SASSpeechTextPaneD
ispatcher
SpeechAudioU
tils
Classes
Lackofcohesionvalue
0 120 180
Threshold
• Trend analysis
• Proof – Improved quality
Tushar Sharma
What can be done with metrics data
• Detect code/design smells:
✦ Insufficient Modularization - WMC or NOM
✦ Hub-like Modularization – Fan-in/Fan-out
✦ Deep Hierarchy – DIT
✦ Multifaceted Abstraction – LCOM
✦ …
Some more metrics
❖ Mood (Metrics for Object-Oriented Design)
✦ Method Hiding Factor (MHF)
✦ ratio of sum of the invisibilities of all methods defined in all
classes to the total number of methods
✦ Attribute Hiding Factor (AHF)
✦ Method Inheritance Factor (MIF)
✦ ratio of the sum of the inherited methods in all classes to the
total number of available methods (locally defined plus
inherited) for all classes
✦ Attribute Inheritance Factor (AIF)
✦ …
Tushar Sharma
Abstractness Vs Instability
• Dependency
• say class Copy depends on KeyboardReader
• “Good dependency”?
• where target of the dependency is stable
• stable - does not depend on anything, not going to change
• Responsible class
• many classes depend on the class
• it’s harder to change
• and therefore, must be stable
Tushar Sharma
• Instability
• Ca - Afferent coupling (Fan-in)
• Ce - Efferent coupling (Fan-out)
Abstractness Vs Instability
• So, shouldn’t we have all classes as stable classes?
• No. System will be unchangeable.
• Therefore, we need some portion of the design to be flexible to
withstand change.
• How? Abstract classes
• Abstractness = #abstract classes / #total classes in the group
Tushar Sharma
Abstractness Vs Instability
(1, 0) - Max
instable and
concrete
(0, 0) - Max
stable and
concrete
(0.5, 0.5) -
striking the
balance
(0, 1) - Max
stable and
abstract
Zone of pain
Zone of uselessness
M
ain
sequence
Abstractness
Instability
(1, 1) - abstract
and max
instable (no
dependents)
Tushar Sharma
Let’s conclude!!
Strive quality not numbers.
Thank you
for your attention.
tusharsharma@ieee.org

More Related Content

What's hot

Software Measurement: Lecture 3. Metrics in Organization
Software Measurement: Lecture 3. Metrics in OrganizationSoftware Measurement: Lecture 3. Metrics in Organization
Software Measurement: Lecture 3. Metrics in OrganizationProgrameter
 
Software Estimation Techniques
Software Estimation TechniquesSoftware Estimation Techniques
Software Estimation Techniqueskamal
 
Software Cost Estimation in Software Engineering SE23
Software Cost Estimation in Software Engineering SE23Software Cost Estimation in Software Engineering SE23
Software Cost Estimation in Software Engineering SE23koolkampus
 
Software Size Estimation
Software Size EstimationSoftware Size Estimation
Software Size EstimationMuhammad Asim
 
10. Software testing overview
10. Software testing overview10. Software testing overview
10. Software testing overviewghayour abbas
 
Software Estimation Part I
Software Estimation Part ISoftware Estimation Part I
Software Estimation Part Isslovepk
 
9. Software Implementation
9. Software Implementation9. Software Implementation
9. Software Implementationghayour abbas
 
Software Coding- Software Coding
Software Coding- Software CodingSoftware Coding- Software Coding
Software Coding- Software CodingNikhil Pandit
 
2.2. language evaluation criteria
2.2. language evaluation criteria2.2. language evaluation criteria
2.2. language evaluation criteriaannahallare_
 
Software engineering
Software engineeringSoftware engineering
Software engineeringSiddu-majety
 
CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V pkaviya
 
A Survey Of Agile Development Methodologies
A Survey Of Agile Development MethodologiesA Survey Of Agile Development Methodologies
A Survey Of Agile Development MethodologiesAbdul Basit
 
Software testing
Software testingSoftware testing
Software testingthaneofife
 
Off the-shelf components (cots)
Off the-shelf components (cots)Off the-shelf components (cots)
Off the-shelf components (cots)Himanshu
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software EngineeringAbhay Vijay
 
Software Estimation
Software EstimationSoftware Estimation
Software EstimationNguyen Hai
 

What's hot (20)

Software Measurement: Lecture 3. Metrics in Organization
Software Measurement: Lecture 3. Metrics in OrganizationSoftware Measurement: Lecture 3. Metrics in Organization
Software Measurement: Lecture 3. Metrics in Organization
 
Software Estimation Techniques
Software Estimation TechniquesSoftware Estimation Techniques
Software Estimation Techniques
 
Software Cost Estimation in Software Engineering SE23
Software Cost Estimation in Software Engineering SE23Software Cost Estimation in Software Engineering SE23
Software Cost Estimation in Software Engineering SE23
 
Software Size Estimation
Software Size EstimationSoftware Size Estimation
Software Size Estimation
 
Metrics
MetricsMetrics
Metrics
 
10. Software testing overview
10. Software testing overview10. Software testing overview
10. Software testing overview
 
Software Estimation Part I
Software Estimation Part ISoftware Estimation Part I
Software Estimation Part I
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
9. Software Implementation
9. Software Implementation9. Software Implementation
9. Software Implementation
 
Software Coding- Software Coding
Software Coding- Software CodingSoftware Coding- Software Coding
Software Coding- Software Coding
 
2.2. language evaluation criteria
2.2. language evaluation criteria2.2. language evaluation criteria
2.2. language evaluation criteria
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V
 
A Survey Of Agile Development Methodologies
A Survey Of Agile Development MethodologiesA Survey Of Agile Development Methodologies
A Survey Of Agile Development Methodologies
 
Cocomo
CocomoCocomo
Cocomo
 
Software testing
Software testingSoftware testing
Software testing
 
Off the-shelf components (cots)
Off the-shelf components (cots)Off the-shelf components (cots)
Off the-shelf components (cots)
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software Engineering
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Software Estimation
Software EstimationSoftware Estimation
Software Estimation
 

Viewers also liked

Technical debt - The elephant in the room
Technical debt - The elephant in the roomTechnical debt - The elephant in the room
Technical debt - The elephant in the roomTushar Sharma
 
Tools for Identifying and Addressing Technical Debt
Tools for Identifying and Addressing Technical DebtTools for Identifying and Addressing Technical Debt
Tools for Identifying and Addressing Technical DebtTushar Sharma
 
Software Metrics & Measurement-Sharbani Bhattacharya
Software Metrics & Measurement-Sharbani BhattacharyaSoftware Metrics & Measurement-Sharbani Bhattacharya
Software Metrics & Measurement-Sharbani BhattacharyaSharbani Bhattacharya
 
Software Metrics
Software MetricsSoftware Metrics
Software Metricsgh0sst
 
Software metrics
Software metricsSoftware metrics
Software metricsIone Donosa
 
Measurement Metrics for Object Oriented Design
Measurement Metrics for Object Oriented DesignMeasurement Metrics for Object Oriented Design
Measurement Metrics for Object Oriented Designzebew
 
Software quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiranSoftware quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiranTanmi Kapoor
 
A Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality IndicatorsA Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality Indicatorsvie_dels
 
Software Engineering Fundamentals
Software Engineering FundamentalsSoftware Engineering Fundamentals
Software Engineering FundamentalsRahul Sudame
 
Software Engineering Practice - Software Metrics and Estimation
Software Engineering Practice - Software Metrics and EstimationSoftware Engineering Practice - Software Metrics and Estimation
Software Engineering Practice - Software Metrics and EstimationRadu_Negulescu
 
Object-Oriented Metrics in Practice
Object-Oriented Metrics in PracticeObject-Oriented Metrics in Practice
Object-Oriented Metrics in PracticeMichele Lanza
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software EngineeringDrishti Bhalla
 
Importance of software quality metrics
Importance of software quality metricsImportance of software quality metrics
Importance of software quality metricsPiyush Sohaney
 
Quality in software industry
Quality in software industryQuality in software industry
Quality in software industryRicha Goel
 

Viewers also liked (20)

Technical debt - The elephant in the room
Technical debt - The elephant in the roomTechnical debt - The elephant in the room
Technical debt - The elephant in the room
 
Tools for Identifying and Addressing Technical Debt
Tools for Identifying and Addressing Technical DebtTools for Identifying and Addressing Technical Debt
Tools for Identifying and Addressing Technical Debt
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
Sw Software Metrics
Sw Software MetricsSw Software Metrics
Sw Software Metrics
 
Software Metrics & Measurement-Sharbani Bhattacharya
Software Metrics & Measurement-Sharbani BhattacharyaSoftware Metrics & Measurement-Sharbani Bhattacharya
Software Metrics & Measurement-Sharbani Bhattacharya
 
Software Metrics
Software MetricsSoftware Metrics
Software Metrics
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
Measurement Metrics for Object Oriented Design
Measurement Metrics for Object Oriented DesignMeasurement Metrics for Object Oriented Design
Measurement Metrics for Object Oriented Design
 
Software quality metric
Software quality metricSoftware quality metric
Software quality metric
 
Software quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiranSoftware quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiran
 
A Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality IndicatorsA Validation of Object-Oriented Design Metrics as Quality Indicators
A Validation of Object-Oriented Design Metrics as Quality Indicators
 
Software Engineering Fundamentals
Software Engineering FundamentalsSoftware Engineering Fundamentals
Software Engineering Fundamentals
 
Software Engineering Practice - Software Metrics and Estimation
Software Engineering Practice - Software Metrics and EstimationSoftware Engineering Practice - Software Metrics and Estimation
Software Engineering Practice - Software Metrics and Estimation
 
Object-Oriented Metrics in Practice
Object-Oriented Metrics in PracticeObject-Oriented Metrics in Practice
Object-Oriented Metrics in Practice
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software Engineering
 
Importance of software quality metrics
Importance of software quality metricsImportance of software quality metrics
Importance of software quality metrics
 
Quality in software industry
Quality in software industryQuality in software industry
Quality in software industry
 
Product metrics
Product metricsProduct metrics
Product metrics
 

Similar to Understanding software metrics

Feature Selection Techniques for Software Fault Prediction (Summary)
Feature Selection Techniques for Software Fault Prediction (Summary)Feature Selection Techniques for Software Fault Prediction (Summary)
Feature Selection Techniques for Software Fault Prediction (Summary)SungdoGu
 
Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...
Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...
Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...Institute of Contemporary Sciences
 
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...ESEM 2014
 
Lecture 3 Requirements and Quality Attributes 16 Sept 2020.pdf
Lecture 3 Requirements and Quality Attributes 16 Sept 2020.pdfLecture 3 Requirements and Quality Attributes 16 Sept 2020.pdf
Lecture 3 Requirements and Quality Attributes 16 Sept 2020.pdfSajalMitra4
 
Presentation by Lionel Briand
Presentation by Lionel BriandPresentation by Lionel Briand
Presentation by Lionel BriandPtidej Team
 
Algorithm ExampleFor the following taskUse the random module .docx
Algorithm ExampleFor the following taskUse the random module .docxAlgorithm ExampleFor the following taskUse the random module .docx
Algorithm ExampleFor the following taskUse the random module .docxdaniahendric
 
Crowdsourced query augmentation through the semantic discovery of domain spec...
Crowdsourced query augmentation through the semantic discovery of domain spec...Crowdsourced query augmentation through the semantic discovery of domain spec...
Crowdsourced query augmentation through the semantic discovery of domain spec...Trey Grainger
 
An Empirical Study on the Adequacy of Testing in Open Source Projects
An Empirical Study on the Adequacy of Testing in Open Source ProjectsAn Empirical Study on the Adequacy of Testing in Open Source Projects
An Empirical Study on the Adequacy of Testing in Open Source ProjectsPavneet Singh Kochhar
 
The Impact of Test Ownership and Team Structure on the Reliability and Effect...
The Impact of Test Ownership and Team Structure on the Reliability and Effect...The Impact of Test Ownership and Team Structure on the Reliability and Effect...
The Impact of Test Ownership and Team Structure on the Reliability and Effect...Kim Herzig
 
B2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draftB2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draftSteve Feldman
 
Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Steve Feldman
 
12 functional-system-testing
12 functional-system-testing12 functional-system-testing
12 functional-system-testingnickynicks76
 
Infosys Interview Questions And Answers 2023
Infosys Interview Questions And Answers 2023Infosys Interview Questions And Answers 2023
Infosys Interview Questions And Answers 2023Simplilearn
 
NDepend Public PPT (2008)
NDepend Public PPT (2008)NDepend Public PPT (2008)
NDepend Public PPT (2008)NDepend
 
What are the Unique Challenges and Opportunities in Systems for ML?
What are the Unique Challenges and Opportunities in Systems for ML?What are the Unique Challenges and Opportunities in Systems for ML?
What are the Unique Challenges and Opportunities in Systems for ML?Matei Zaharia
 
Keynote at IWLS 2017
Keynote at IWLS 2017Keynote at IWLS 2017
Keynote at IWLS 2017Manish Pandey
 
Training and Placement Portal
Training and Placement PortalTraining and Placement Portal
Training and Placement PortalIRJET Journal
 

Similar to Understanding software metrics (20)

Feature Selection Techniques for Software Fault Prediction (Summary)
Feature Selection Techniques for Software Fault Prediction (Summary)Feature Selection Techniques for Software Fault Prediction (Summary)
Feature Selection Techniques for Software Fault Prediction (Summary)
 
Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...
Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...
Improving Search Relevance in Elasticsearch Using Machine Learning - Milorad ...
 
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
 
Lecture 3 Requirements and Quality Attributes 16 Sept 2020.pdf
Lecture 3 Requirements and Quality Attributes 16 Sept 2020.pdfLecture 3 Requirements and Quality Attributes 16 Sept 2020.pdf
Lecture 3 Requirements and Quality Attributes 16 Sept 2020.pdf
 
Presentation by Lionel Briand
Presentation by Lionel BriandPresentation by Lionel Briand
Presentation by Lionel Briand
 
Algorithm ExampleFor the following taskUse the random module .docx
Algorithm ExampleFor the following taskUse the random module .docxAlgorithm ExampleFor the following taskUse the random module .docx
Algorithm ExampleFor the following taskUse the random module .docx
 
Crowdsourced query augmentation through the semantic discovery of domain spec...
Crowdsourced query augmentation through the semantic discovery of domain spec...Crowdsourced query augmentation through the semantic discovery of domain spec...
Crowdsourced query augmentation through the semantic discovery of domain spec...
 
An Empirical Study on the Adequacy of Testing in Open Source Projects
An Empirical Study on the Adequacy of Testing in Open Source ProjectsAn Empirical Study on the Adequacy of Testing in Open Source Projects
An Empirical Study on the Adequacy of Testing in Open Source Projects
 
The Impact of Test Ownership and Team Structure on the Reliability and Effect...
The Impact of Test Ownership and Team Structure on the Reliability and Effect...The Impact of Test Ownership and Team Structure on the Reliability and Effect...
The Impact of Test Ownership and Team Structure on the Reliability and Effect...
 
Basic Terminology of Data Structure.pptx
Basic Terminology of Data Structure.pptxBasic Terminology of Data Structure.pptx
Basic Terminology of Data Structure.pptx
 
Man.ppt
Man.pptMan.ppt
Man.ppt
 
N depend & cql
N depend & cqlN depend & cql
N depend & cql
 
B2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draftB2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draft
 
Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07
 
12 functional-system-testing
12 functional-system-testing12 functional-system-testing
12 functional-system-testing
 
Infosys Interview Questions And Answers 2023
Infosys Interview Questions And Answers 2023Infosys Interview Questions And Answers 2023
Infosys Interview Questions And Answers 2023
 
NDepend Public PPT (2008)
NDepend Public PPT (2008)NDepend Public PPT (2008)
NDepend Public PPT (2008)
 
What are the Unique Challenges and Opportunities in Systems for ML?
What are the Unique Challenges and Opportunities in Systems for ML?What are the Unique Challenges and Opportunities in Systems for ML?
What are the Unique Challenges and Opportunities in Systems for ML?
 
Keynote at IWLS 2017
Keynote at IWLS 2017Keynote at IWLS 2017
Keynote at IWLS 2017
 
Training and Placement Portal
Training and Placement PortalTraining and Placement Portal
Training and Placement Portal
 

More from Tushar Sharma

House of Cards: Code Smells in Open-source C# Repositories
House of Cards: Code Smells in Open-source C# RepositoriesHouse of Cards: Code Smells in Open-source C# Repositories
House of Cards: Code Smells in Open-source C# RepositoriesTushar Sharma
 
The tail of two source-code analysis tools - Learning and experiences
The tail of two source-code analysis tools - Learning and experiencesThe tail of two source-code analysis tools - Learning and experiences
The tail of two source-code analysis tools - Learning and experiencesTushar Sharma
 
Designite: A Customizable Tool for Smell Mining in C# Repositories
Designite: A Customizable Tool for Smell Mining in C# RepositoriesDesignite: A Customizable Tool for Smell Mining in C# Repositories
Designite: A Customizable Tool for Smell Mining in C# RepositoriesTushar Sharma
 
Writing Maintainable Code
Writing Maintainable Code Writing Maintainable Code
Writing Maintainable Code Tushar Sharma
 
FOSDEM - Does your configuration code smell?
FOSDEM - Does your configuration code smell?FOSDEM - Does your configuration code smell?
FOSDEM - Does your configuration code smell?Tushar Sharma
 
Achieving Design Agility by Refactoring Design Smells
Achieving Design Agility by Refactoring Design SmellsAchieving Design Agility by Refactoring Design Smells
Achieving Design Agility by Refactoring Design SmellsTushar Sharma
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?Tushar Sharma
 
Designite – Software Design Quality Assessment Tool
Designite – Software Design Quality Assessment ToolDesignite – Software Design Quality Assessment Tool
Designite – Software Design Quality Assessment ToolTushar Sharma
 
Does Your Configuration Code Smell?
Does Your Configuration Code Smell?Does Your Configuration Code Smell?
Does Your Configuration Code Smell?Tushar Sharma
 
Pragmatic Technical Debt Management
Pragmatic Technical Debt ManagementPragmatic Technical Debt Management
Pragmatic Technical Debt ManagementTushar Sharma
 
Infographic - Pragmatic Technical Debt Management
Infographic - Pragmatic Technical Debt ManagementInfographic - Pragmatic Technical Debt Management
Infographic - Pragmatic Technical Debt ManagementTushar Sharma
 
Applying Design Principles in Practice
Applying Design Principles in PracticeApplying Design Principles in Practice
Applying Design Principles in PracticeTushar Sharma
 
Why care about technical debt?
Why care about technical debt?Why care about technical debt?
Why care about technical debt?Tushar Sharma
 
Does your design smell?
Does your design smell?Does your design smell?
Does your design smell?Tushar Sharma
 
A Checklist for Design Reviews
A Checklist for Design ReviewsA Checklist for Design Reviews
A Checklist for Design ReviewsTushar Sharma
 
Tools for refactoring
Tools for refactoringTools for refactoring
Tools for refactoringTushar Sharma
 
Towards a Principle-based Classification of Structural Design Smells
Towards a Principle-based Classification of Structural Design SmellsTowards a Principle-based Classification of Structural Design Smells
Towards a Principle-based Classification of Structural Design SmellsTushar Sharma
 
PHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
PHAME: Principles of Hierarchy Abstraction Modularization and EncapsulationPHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
PHAME: Principles of Hierarchy Abstraction Modularization and EncapsulationTushar Sharma
 
Refactoring for Design Smells - ICSE 2014 Tutorial
Refactoring for Design Smells - ICSE 2014 TutorialRefactoring for Design Smells - ICSE 2014 Tutorial
Refactoring for Design Smells - ICSE 2014 TutorialTushar Sharma
 
Refactoring for Software Design Smells: Managing Technical Debt
Refactoring for Software Design Smells: Managing Technical DebtRefactoring for Software Design Smells: Managing Technical Debt
Refactoring for Software Design Smells: Managing Technical DebtTushar Sharma
 

More from Tushar Sharma (20)

House of Cards: Code Smells in Open-source C# Repositories
House of Cards: Code Smells in Open-source C# RepositoriesHouse of Cards: Code Smells in Open-source C# Repositories
House of Cards: Code Smells in Open-source C# Repositories
 
The tail of two source-code analysis tools - Learning and experiences
The tail of two source-code analysis tools - Learning and experiencesThe tail of two source-code analysis tools - Learning and experiences
The tail of two source-code analysis tools - Learning and experiences
 
Designite: A Customizable Tool for Smell Mining in C# Repositories
Designite: A Customizable Tool for Smell Mining in C# RepositoriesDesignite: A Customizable Tool for Smell Mining in C# Repositories
Designite: A Customizable Tool for Smell Mining in C# Repositories
 
Writing Maintainable Code
Writing Maintainable Code Writing Maintainable Code
Writing Maintainable Code
 
FOSDEM - Does your configuration code smell?
FOSDEM - Does your configuration code smell?FOSDEM - Does your configuration code smell?
FOSDEM - Does your configuration code smell?
 
Achieving Design Agility by Refactoring Design Smells
Achieving Design Agility by Refactoring Design SmellsAchieving Design Agility by Refactoring Design Smells
Achieving Design Agility by Refactoring Design Smells
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?
 
Designite – Software Design Quality Assessment Tool
Designite – Software Design Quality Assessment ToolDesignite – Software Design Quality Assessment Tool
Designite – Software Design Quality Assessment Tool
 
Does Your Configuration Code Smell?
Does Your Configuration Code Smell?Does Your Configuration Code Smell?
Does Your Configuration Code Smell?
 
Pragmatic Technical Debt Management
Pragmatic Technical Debt ManagementPragmatic Technical Debt Management
Pragmatic Technical Debt Management
 
Infographic - Pragmatic Technical Debt Management
Infographic - Pragmatic Technical Debt ManagementInfographic - Pragmatic Technical Debt Management
Infographic - Pragmatic Technical Debt Management
 
Applying Design Principles in Practice
Applying Design Principles in PracticeApplying Design Principles in Practice
Applying Design Principles in Practice
 
Why care about technical debt?
Why care about technical debt?Why care about technical debt?
Why care about technical debt?
 
Does your design smell?
Does your design smell?Does your design smell?
Does your design smell?
 
A Checklist for Design Reviews
A Checklist for Design ReviewsA Checklist for Design Reviews
A Checklist for Design Reviews
 
Tools for refactoring
Tools for refactoringTools for refactoring
Tools for refactoring
 
Towards a Principle-based Classification of Structural Design Smells
Towards a Principle-based Classification of Structural Design SmellsTowards a Principle-based Classification of Structural Design Smells
Towards a Principle-based Classification of Structural Design Smells
 
PHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
PHAME: Principles of Hierarchy Abstraction Modularization and EncapsulationPHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
PHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
 
Refactoring for Design Smells - ICSE 2014 Tutorial
Refactoring for Design Smells - ICSE 2014 TutorialRefactoring for Design Smells - ICSE 2014 Tutorial
Refactoring for Design Smells - ICSE 2014 Tutorial
 
Refactoring for Software Design Smells: Managing Technical Debt
Refactoring for Software Design Smells: Managing Technical DebtRefactoring for Software Design Smells: Managing Technical Debt
Refactoring for Software Design Smells: Managing Technical Debt
 

Recently uploaded

Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxBoston Institute of Analytics
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in collegessuser7a7cd61
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our WorldEduminds Learning
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfchwongval
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 

Recently uploaded (20)

Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in college
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our World
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdf
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 

Understanding software metrics

  • 2. Tushar Sharma Agenda OO metrics and their classification Using metrics in practice Advanced stuff… Metrics: What and why
  • 3. Software Metrics - What & Why? A software metric is a measure of some property of a software system. Why? “Measurement is the first step that leads to control and eventually to improvement. If you can’t measure something, you can’t understand it.” (by James Harrington)
  • 4. Tushar Sharma Object-oriented Metrics Size Complexity Cohesion & Coupling Project Namespace Type Method LOC NOC NON LOC NOC LOC NOM NOF DIT NC RFC LOC NP WMC CC LCOM CBO Fan-in/ Fan-out
  • 5. Tushar Sharma OO Metrics - Size • Large entities make the comprehension difficult. • Large entities indicate presence of various smells. LOC Lines Of Code NON Number Of Namespaces NOC Number Of Classes NOM Number Of Methods NOF Number Of Fields
  • 6. Tushar Sharma OO Metrics - Size The response set of a class is a set of methods that can potentially be executed in response to a message received by an object of that class. • Larger the number of methods that can be invoked, the greater the complexity of the class. • If a large number of methods can be invoked in response to a message, the testing and debugging of the class becomes more complicated . RFC Response For Class
  • 7. Tushar Sharma OO Metrics - Size (Hierarchy) • Deep inheritance trees make the comprehension difficult. • The deeper a class is in the hierarchy, the greater the number of methods it is likely to inherit, making it more complex to predict its behaviour. • Again, wide inheritance trees make the comprehension difficult. • A wide hierarchy indicates missing intermediate inheritance level that in turn may lead to code duplication. DIT Depth of Inheritance Tree NC Number of Children
  • 8. Tushar Sharma OO Metrics - Cohesion and Coupling Consider a class C with n methods M1, M2..., Mn. Let {Ij} = set of instance variables used by method Mi. There are n such sets I1 ,…, In • P = {(Ii, Ij) | (Ii ∩ Ij ) = ∅} • Q = {(Ii, Ij) | (Ii ∩ Ij ) ≠ ∅} LCOM = |P| - |Q|, if |P| > |Q| = 0, otherwise • High LCOM indicate the violation of the Single Responsibility Principle. LCOM Lack of Cohesion Of Methods
  • 9. Tushar Sharma OO Metrics - Cohesion and Coupling CBO for a class is a count of the number of other classes to which it is coupled. • Excessive coupling between object classes is detrimental to modular design and prevents reuse. The more independent a class is, the easier it is to reuse it in another application. • A measure of coupling is useful to determine how complex the testing of various parts of a design are likely to be. The higher the inter-object class coupling, the more rigorous the testing needs to be. CBO Coupling Between Object classes
  • 10. Tushar Sharma OO Metrics - Complexity • CC - It is a quantitative measure of the number of linearly independent paths through a program's source code. • WMC – Sum of CC of each method in the class • The number of methods and the complexity of methods involved is a predictor of how much time and effort is required to develop and maintain the class. CC Cyclomatic Complexity WMC Weighted Methods per Class
  • 11. Tushar Sharma Using metrics in practice - tools C/C++ CppDepend Infusion Source Monitor C# Designite NDepend Java Infusion Source Monitor
  • 12. Tushar Sharma Using metrics in practice • There is no one single widely accepted standard for metrics thresholds. • There are some guidelines and rules of thumb! Metric - Recommended Threshold LOC (Method) - 50 LOC (File) - 500 NOC - 9 DIT - 5 LCOM - 0.80 NOM - 30 CBO - 6 CC - 10 WMC - 100 % Duplication - 4% Metric thresholds
  • 13. Tushar Sharma Using metrics in practice What if you want to perform an analysis with customized metric thresholds http://www.designite-tools.com
  • 14. Tushar Sharma What can be done with metrics data • Indicator of “Structural Quality” • Refactoring candidates LackofCohesion 0 500 1000 1500 2000 2500 3000 3500 createFaxFaxSender PrintSender SASC ontext SASFoldableTableC ellW idget SASFoldableTable SASSortFoldableTable SASFoldableD ynam icC olum nScrollTable SASFoldableD ynam icTable SASSortTable SASLaterality SASProcedureTree SASSiriusLPA SASProcedureTreeU serO bject PortalApplication PortalR ISApplicationR adiologist SASServerH essianProxy C lientC onfig U serPreferences SASC riteria SASSpeechTextPaneD ispatcher SpeechAudioU tils Classes Lackofcohesionvalue 0 120 180 Threshold • Trend analysis • Proof – Improved quality
  • 15. Tushar Sharma What can be done with metrics data • Detect code/design smells: ✦ Insufficient Modularization - WMC or NOM ✦ Hub-like Modularization – Fan-in/Fan-out ✦ Deep Hierarchy – DIT ✦ Multifaceted Abstraction – LCOM ✦ …
  • 16. Some more metrics ❖ Mood (Metrics for Object-Oriented Design) ✦ Method Hiding Factor (MHF) ✦ ratio of sum of the invisibilities of all methods defined in all classes to the total number of methods ✦ Attribute Hiding Factor (AHF) ✦ Method Inheritance Factor (MIF) ✦ ratio of the sum of the inherited methods in all classes to the total number of available methods (locally defined plus inherited) for all classes ✦ Attribute Inheritance Factor (AIF) ✦ …
  • 17. Tushar Sharma Abstractness Vs Instability • Dependency • say class Copy depends on KeyboardReader • “Good dependency”? • where target of the dependency is stable • stable - does not depend on anything, not going to change • Responsible class • many classes depend on the class • it’s harder to change • and therefore, must be stable
  • 18. Tushar Sharma • Instability • Ca - Afferent coupling (Fan-in) • Ce - Efferent coupling (Fan-out) Abstractness Vs Instability • So, shouldn’t we have all classes as stable classes? • No. System will be unchangeable. • Therefore, we need some portion of the design to be flexible to withstand change. • How? Abstract classes • Abstractness = #abstract classes / #total classes in the group
  • 19. Tushar Sharma Abstractness Vs Instability (1, 0) - Max instable and concrete (0, 0) - Max stable and concrete (0.5, 0.5) - striking the balance (0, 1) - Max stable and abstract Zone of pain Zone of uselessness M ain sequence Abstractness Instability (1, 1) - abstract and max instable (no dependents)
  • 21. Thank you for your attention. tusharsharma@ieee.org