SlideShare a Scribd company logo
1 of 18
CODE METRICS
Eng. Mohammad R. Katby
Which line of code easier to understand?
int x = x + 1;
int x = y + 1;
or
CODE METRICS Eng. Mohammad R. Katby
Agenda
■ What are the code measurement units?
■ What we are going to measure?
■ Why we need code metrics
■ What are code metrics
What are Code Metrics
■ Length
■ Vocabulary
■ Difficulty
■ Volume
■ Effort
■ Bugs
■ Structuredness
■ Complexity
■ Maintainability
■ Independability
Why we need measurements?
■ Without measurement you cannot understand code faults
■ See whether improvement can be made or not
■ Simply you can’t be Electrician if you can’t measure the voltage
Pioneers of Code Metrics
Thomas J. McCabe - 1976 Maurice Halstead - 1977
int x = x + 1;
Operators
Operands
Operand: 4, Unique: 3
Operator: 3, Unique: 3
OD = 4; UOD = 3
OP = 3; UOP = 3
Halstead metrics “Primitives”
■ Length (LTH) = OP + OD = 3 + 4 = 7
■ Vocabulary (VOC) = UOP + UOD = 3 + 3 = 6
■ Difficulty (DIF) = (UOP / 2) * (OD / UOD) = (3 / 2) * (4 / 3) = 1.99
■ OP = 3, UOP = 3, OD = 4, UOD = 4
■ LTH = 3 + 4 = 7
■ VOC = 3 + 4 = 7
■ DIF = (3 / 2) * (4 / 4) = 1.5
int x = x + 1;
int x = y + 1;
Halstead metrics “Derived”
■ Volume (VOL) = LTH * Log2(VOC) = 7 * 2.58 = 18.06
– You can view this as the ‘bulk’ of the code
– how much information does the reader of the code have to absorb to understand
its meaning
– biggest influence on theVolume metric is the Halstead length
Halstead metrics “Derived”
■ Bugs (BUG) =VOL / 3000 = 18.06 / 3000
– Estimates how many bugs you are likely to find in the system.
Halstead metrics “Derived”
■ Effort (EFF) = DIF *VOL = 1.99 * 18.06 = 38.96 / 18 = 2.16 (sec)
– The amount of mental effort required to recreate the software
Cyclomatic Complexity
■ Counting the number of decisions made in our source code.
■ Determine number test cases that need to be written
■ there is no exact limit that fits all organizations. However, a limit
of 10 is a good for such our industry
■ Measure: Strcuturedness, Complexity
Class Coupling
■ Measure how many classes a single class uses
■ Has been shown to be an accurate predictor of software failure
■ High coupling indicates design that is difficult to reuse and maintain
■ There is no limit that fits all organizations. However, a limit of 9 is optimal
■ Measure: Reusability, Maintainability,Changeability
Depth of Inheritance
■ The maximum length from the node to the root of the tree
■ Harder to predict behavior
■ Increase complexity of design since more classes and methods are involved
■ Have a greater potential for reusing
■ Several researches suggest that a DIT around 5 or 6 should be an upper limit
Maintainability Index
■ High value means better maintainability.
– LOW - red rating is a rating between 0 and 9
– MODERIATE - yellow rating is between 10 and 19
– GOOD - green rating is between 20 and 100
■ Maintainability Index = MAX(0,(171 – 5.2 * log(HalsteadVolume) – 0.23 * (Cyclomatic
Complexity) – 16.2 * log(Lines of Code))*100 / 171)
■
Levels of Measurement
■ Method
■ Class
■ Package and system
References
■ http://moosehead.cis.umassd.edu/cis580/readings/OO_Design_Complexity_Metrics.p
df
■ http://www.mccabe.com/pdf/mccabe-nist235r.pdf
■ http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.104.4041&rep=rep1&type=
pdf
■ http://www.campwoodsw.com/sourcemonitor.html
■ https://sourceforge.net/projects/metrics/

More Related Content

What's hot

Introduction to software testing
Introduction to software testingIntroduction to software testing
Introduction to software testingHadi Fadlallah
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategiesSHREEHARI WADAWADAGI
 
Software maintenance ppt
Software maintenance pptSoftware maintenance ppt
Software maintenance pptAnas Usman
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01Sidra Ashraf
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction Sarmad Ali
 
verification and validation
verification and validationverification and validation
verification and validationDinesh Pasi
 
Software Engineering - chp8- deployment
Software Engineering - chp8- deploymentSoftware Engineering - chp8- deployment
Software Engineering - chp8- deploymentLilia Sfaxi
 
CS8494 SOFTWARE ENGINEERING Unit-2
CS8494 SOFTWARE ENGINEERING Unit-2CS8494 SOFTWARE ENGINEERING Unit-2
CS8494 SOFTWARE ENGINEERING Unit-2SIMONTHOMAS S
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart Shivam Sharma
 
The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debuggingsvilen.ivanov
 
Advanced topics in software engineering
Advanced topics in software engineeringAdvanced topics in software engineering
Advanced topics in software engineeringRupesh Vaishnav
 
Chapter 15 software product metrics
Chapter 15 software product metricsChapter 15 software product metrics
Chapter 15 software product metricsSHREEHARI WADAWADAGI
 
What is Integration Testing? | Edureka
What is Integration Testing? | EdurekaWhat is Integration Testing? | Edureka
What is Integration Testing? | EdurekaEdureka!
 
Superscalar & superpipeline processor
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processorMuhammad Ishaq
 

What's hot (20)

Introduction to software testing
Introduction to software testingIntroduction to software testing
Introduction to software testing
 
Introduction to White box testing
Introduction to White box testingIntroduction to White box testing
Introduction to White box testing
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategies
 
Software maintenance ppt
Software maintenance pptSoftware maintenance ppt
Software maintenance ppt
 
Software Myths
Software MythsSoftware Myths
Software Myths
 
Software Quality Metrics
Software Quality MetricsSoftware Quality Metrics
Software Quality Metrics
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
verification and validation
verification and validationverification and validation
verification and validation
 
Software Engineering - chp8- deployment
Software Engineering - chp8- deploymentSoftware Engineering - chp8- deployment
Software Engineering - chp8- deployment
 
CS8494 SOFTWARE ENGINEERING Unit-2
CS8494 SOFTWARE ENGINEERING Unit-2CS8494 SOFTWARE ENGINEERING Unit-2
CS8494 SOFTWARE ENGINEERING Unit-2
 
Software process
Software processSoftware process
Software process
 
Software testing
Software testingSoftware testing
Software testing
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart
 
Software coding and testing
Software coding and testingSoftware coding and testing
Software coding and testing
 
The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debugging
 
Advanced topics in software engineering
Advanced topics in software engineeringAdvanced topics in software engineering
Advanced topics in software engineering
 
Chapter 15 software product metrics
Chapter 15 software product metricsChapter 15 software product metrics
Chapter 15 software product metrics
 
What is Integration Testing? | Edureka
What is Integration Testing? | EdurekaWhat is Integration Testing? | Edureka
What is Integration Testing? | Edureka
 
Superscalar & superpipeline processor
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processor
 

Viewers also liked

Principal 4 Enabling A Holistic Approach
Principal 4 Enabling A Holistic ApproachPrincipal 4 Enabling A Holistic Approach
Principal 4 Enabling A Holistic ApproachMohammad Reda Katby
 
Geospatial analytics data science sg meetup
Geospatial analytics   data science sg meetupGeospatial analytics   data science sg meetup
Geospatial analytics data science sg meetupNUS-ISS
 

Viewers also liked (6)

Object oriented design
Object oriented designObject oriented design
Object oriented design
 
Decorator pattern
Decorator patternDecorator pattern
Decorator pattern
 
Principal 4 Enabling A Holistic Approach
Principal 4 Enabling A Holistic ApproachPrincipal 4 Enabling A Holistic Approach
Principal 4 Enabling A Holistic Approach
 
COBIT5 Implementation Guidance
COBIT5 Implementation GuidanceCOBIT5 Implementation Guidance
COBIT5 Implementation Guidance
 
What is Cobit
What is CobitWhat is Cobit
What is Cobit
 
Geospatial analytics data science sg meetup
Geospatial analytics   data science sg meetupGeospatial analytics   data science sg meetup
Geospatial analytics data science sg meetup
 

Similar to Code metrics

01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015Hira Gul
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfHarshNagda5
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit onessuserb7c8b8
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptracha49
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptBhargaviDalal4
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structureSelf-Employed
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxJeevaMCSEKIOT
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptKirti Verma
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsAkhil Kaushik
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 

Similar to Code metrics (20)

01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdf
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
 
04 performance
04 performance04 performance
04 performance
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptx
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Unit no_1.pptx
Unit no_1.pptxUnit no_1.pptx
Unit no_1.pptx
 

More from Mohammad Reda Katby

Global Artificial Intelligence (AI) Index
Global Artificial Intelligence (AI) IndexGlobal Artificial Intelligence (AI) Index
Global Artificial Intelligence (AI) IndexMohammad Reda Katby
 
COBIT 5 - Principal 5 Separating Governance From Management
COBIT 5 - Principal 5 Separating Governance From ManagementCOBIT 5 - Principal 5 Separating Governance From Management
COBIT 5 - Principal 5 Separating Governance From ManagementMohammad Reda Katby
 
COBIT 5 - Principal 3 Applying A Single Integrated Framework
COBIT 5 - Principal 3 Applying A Single Integrated FrameworkCOBIT 5 - Principal 3 Applying A Single Integrated Framework
COBIT 5 - Principal 3 Applying A Single Integrated FrameworkMohammad Reda Katby
 
COBIT 5 Principal 2 Covering the Enterprise End-To-End
COBIT 5 Principal 2 Covering the Enterprise End-To-EndCOBIT 5 Principal 2 Covering the Enterprise End-To-End
COBIT 5 Principal 2 Covering the Enterprise End-To-EndMohammad Reda Katby
 
Cobit5 Principal 1 Meeting Stakeholder Needs
Cobit5 Principal 1 Meeting Stakeholder NeedsCobit5 Principal 1 Meeting Stakeholder Needs
Cobit5 Principal 1 Meeting Stakeholder NeedsMohammad Reda Katby
 

More from Mohammad Reda Katby (7)

Global Artificial Intelligence (AI) Index
Global Artificial Intelligence (AI) IndexGlobal Artificial Intelligence (AI) Index
Global Artificial Intelligence (AI) Index
 
Code metrics
Code metricsCode metrics
Code metrics
 
COBIT 5 - Principal 5 Separating Governance From Management
COBIT 5 - Principal 5 Separating Governance From ManagementCOBIT 5 - Principal 5 Separating Governance From Management
COBIT 5 - Principal 5 Separating Governance From Management
 
COBIT 5 - Principal 3 Applying A Single Integrated Framework
COBIT 5 - Principal 3 Applying A Single Integrated FrameworkCOBIT 5 - Principal 3 Applying A Single Integrated Framework
COBIT 5 - Principal 3 Applying A Single Integrated Framework
 
COBIT 5 Principal 2 Covering the Enterprise End-To-End
COBIT 5 Principal 2 Covering the Enterprise End-To-EndCOBIT 5 Principal 2 Covering the Enterprise End-To-End
COBIT 5 Principal 2 Covering the Enterprise End-To-End
 
Cobit5 Principal 1 Meeting Stakeholder Needs
Cobit5 Principal 1 Meeting Stakeholder NeedsCobit5 Principal 1 Meeting Stakeholder Needs
Cobit5 Principal 1 Meeting Stakeholder Needs
 
COBIT5 Introduction
COBIT5 IntroductionCOBIT5 Introduction
COBIT5 Introduction
 

Recently uploaded

Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Pooja Nehwal
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...amitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...amitlee9823
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsJoseMangaJr1
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...amitlee9823
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...karishmasinghjnh
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 

Recently uploaded (20)

Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 

Code metrics

  • 2. Which line of code easier to understand? int x = x + 1; int x = y + 1; or CODE METRICS Eng. Mohammad R. Katby
  • 3. Agenda ■ What are the code measurement units? ■ What we are going to measure? ■ Why we need code metrics ■ What are code metrics
  • 4.
  • 5. What are Code Metrics ■ Length ■ Vocabulary ■ Difficulty ■ Volume ■ Effort ■ Bugs ■ Structuredness ■ Complexity ■ Maintainability ■ Independability
  • 6. Why we need measurements? ■ Without measurement you cannot understand code faults ■ See whether improvement can be made or not ■ Simply you can’t be Electrician if you can’t measure the voltage
  • 7. Pioneers of Code Metrics Thomas J. McCabe - 1976 Maurice Halstead - 1977
  • 8. int x = x + 1; Operators Operands Operand: 4, Unique: 3 Operator: 3, Unique: 3 OD = 4; UOD = 3 OP = 3; UOP = 3
  • 9. Halstead metrics “Primitives” ■ Length (LTH) = OP + OD = 3 + 4 = 7 ■ Vocabulary (VOC) = UOP + UOD = 3 + 3 = 6 ■ Difficulty (DIF) = (UOP / 2) * (OD / UOD) = (3 / 2) * (4 / 3) = 1.99 ■ OP = 3, UOP = 3, OD = 4, UOD = 4 ■ LTH = 3 + 4 = 7 ■ VOC = 3 + 4 = 7 ■ DIF = (3 / 2) * (4 / 4) = 1.5 int x = x + 1; int x = y + 1;
  • 10. Halstead metrics “Derived” ■ Volume (VOL) = LTH * Log2(VOC) = 7 * 2.58 = 18.06 – You can view this as the ‘bulk’ of the code – how much information does the reader of the code have to absorb to understand its meaning – biggest influence on theVolume metric is the Halstead length
  • 11. Halstead metrics “Derived” ■ Bugs (BUG) =VOL / 3000 = 18.06 / 3000 – Estimates how many bugs you are likely to find in the system.
  • 12. Halstead metrics “Derived” ■ Effort (EFF) = DIF *VOL = 1.99 * 18.06 = 38.96 / 18 = 2.16 (sec) – The amount of mental effort required to recreate the software
  • 13. Cyclomatic Complexity ■ Counting the number of decisions made in our source code. ■ Determine number test cases that need to be written ■ there is no exact limit that fits all organizations. However, a limit of 10 is a good for such our industry ■ Measure: Strcuturedness, Complexity
  • 14. Class Coupling ■ Measure how many classes a single class uses ■ Has been shown to be an accurate predictor of software failure ■ High coupling indicates design that is difficult to reuse and maintain ■ There is no limit that fits all organizations. However, a limit of 9 is optimal ■ Measure: Reusability, Maintainability,Changeability
  • 15. Depth of Inheritance ■ The maximum length from the node to the root of the tree ■ Harder to predict behavior ■ Increase complexity of design since more classes and methods are involved ■ Have a greater potential for reusing ■ Several researches suggest that a DIT around 5 or 6 should be an upper limit
  • 16. Maintainability Index ■ High value means better maintainability. – LOW - red rating is a rating between 0 and 9 – MODERIATE - yellow rating is between 10 and 19 – GOOD - green rating is between 20 and 100 ■ Maintainability Index = MAX(0,(171 – 5.2 * log(HalsteadVolume) – 0.23 * (Cyclomatic Complexity) – 16.2 * log(Lines of Code))*100 / 171) ■
  • 17. Levels of Measurement ■ Method ■ Class ■ Package and system
  • 18. References ■ http://moosehead.cis.umassd.edu/cis580/readings/OO_Design_Complexity_Metrics.p df ■ http://www.mccabe.com/pdf/mccabe-nist235r.pdf ■ http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.104.4041&rep=rep1&type= pdf ■ http://www.campwoodsw.com/sourcemonitor.html ■ https://sourceforge.net/projects/metrics/