SlideShare une entreprise Scribd logo
1  sur  62
Télécharger pour lire hors ligne
IMPORTANT METRICS
@mscottford
BY M. SCOTT FORD

CO-FOUNDER & CHIEF CODE WHISPERER, CORGIBYTES
FOR MEASURING CODE HEALTH
@mscottford
@mscottford
METRICS YOUR DOCTOR USES
@mscottford
AGE?
METRICS YOUR DOCTOR USES
@mscottford
AGE?
WEIGHT?
METRICS YOUR DOCTOR USES
@mscottford
AGE?
WEIGHT?
HEIGHT?
METRICS YOUR DOCTOR USES
@mscottford
AGE?
WEIGHT?
HEIGHT?
METRICS YOUR DOCTOR USES
TEMPERATURE?
@mscottford
AGE?
WEIGHT?
HEIGHT?
BLOOD O2 LEVEL?
METRICS YOUR DOCTOR USES
TEMPERATURE?
@mscottford
AGE?
WEIGHT?
HEIGHT?
BLOOD O2 LEVEL?
METRICS YOUR DOCTOR USES
TEMPERATURE?
BLOOD PRESSURE?
@mscottford
AGE?
WEIGHT?
HEIGHT?
BLOOD O2 LEVEL?
ALL OF THESE ARE USED TOGETHER
TEMPERATURE?
BLOOD PRESSURE?
@mscottford
AGE?
WEIGHT?
HEIGHT?
BLOOD O2 LEVEL?
TOGETHER THEY PROVIDE SOME HINTS
TEMPERATURE?
BLOOD PRESSURE?
ABOUT ME
@mscottford
@mscottford
CHIEF CODE WHISPERER
CO-FOUNDER AND
@mscottford
WE PERFORM CODE INSPECTIONS
@mscottford
WE’VE LOOKED AT A LOT OF PROJECTS
WHAT METRICS DO WE LOOK AT?
@mscottford
@mscottford
???
???
???
@mscottford
???
???
CHURN
@mscottford
CHURN
A measure of how many
times file has changed
over a specific amount of
time
@mscottford
LIFETIME CHURN
A measure of how many
times file has changed
over the life of a project
@mscottford
RECENT CHURN
A measure of how many
times file has changed
during the last 3 months
@mscottford
???
???
CHURN
@mscottford
???
CODE COVERAGE
CHURN
@mscottford
CODE COVERAGE
A measure of how much of
the application is executed
when a test is performed
@mscottford
ACCEPTANCE TEST
CODE COVERAGE
A measure of how much of
the application is executed
when the acceptance tests
are run
@mscottford
INTEGRATION TEST
CODE COVERAGE
A measure of how much of
the application is executed
when the integration tests
are run
@mscottford
UNIT TEST
CODE COVERAGE
A measure of how much of
the application is executed
when the unit tests are run
@mscottford
???
CODE COVERAGE
CHURN
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
@mscottford
COMPLEXITY
A measure of how difficult
a chunk of code is to work
with
@mscottford
A measure of unique code
paths for a block of code
CYCLOMATIC
COMPLEXITY
@mscottford
A measure of the cognitive
effort required to
understand a block of code
COGNITIVE
COMPLEXITY
@mscottford
HOW DO WE COLLECT THESE METRICS?
CHURN
• git-churn script by Corey Haines & Gary Bernhardt
• https://github.com/garybernhardt/dotfiles/blob/master/bin/git-
churn
@mscottford
CODE COVERAGE
• Run tests with code coverage collection tool
• These vary by language
•Ruby: simplecov, rcov
•Python: coverage.py
• C#/.NET: dotCover, NCover, OpenCover
•Java: Clover, JCov, JCoCo, OpenClover, Cobertura,
•JavaScript: Istanbul, Jest
@mscottford
COMPLEXITY
• Run a static analysis tool to collect the data
• These also vary by language
• Ruby: rubocop, flog
• Python: radon
• C#/.NET: MS Visual Studio, NDepend, ReSharper,
SonarQube
• Java: PMD, GMetrics, IntelliJ, SonarQube,
• JavaScript: ESLint, JSHint, ccmj
@mscottford
WHY THESE METRICS?
@mscottford
@mscottford
CHURN
Code that has changed in
the past is more likely to
change in the future.
A good stand-in for single
responsibility principle.
@mscottford
CODE COVERAGE
Code that is tested is safer
to change.
@mscottford
COMPLEXITY
The more complex code is
the more dangerous to
change.
@mscottford
WHAT ARE ‘GOOD’ METRIC VALUES?
@mscottford
CHURN
Low is better. High is not
bad, but outliers are.
Recent churn is more
important than lifetime
churn.
@mscottford
CODE COVERAGE
100% across the entire
codebase is asymptotic.
85% is a reasonable target.
Unit > Integration >
Acceptance
@mscottford
COMPLEXITY
Provides best info at
method level:
1 - 5 : Good
6 - 10 : Complex
> 10 : Extremely Complex
@mscottford
USING THESE METRICS TOGETHER
@mscottford
@mscottford
LET’S EXPLORE COMMON SCENARIOS
@mscottford
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
HEALTHY
@mscottford
COMPLEXITY LOW
CODE COVERAGE HIGH
CHURN LOW
HEALTHY
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
DESIGN SMELL
@mscottford
COMPLEXITY LOW
CODE COVERAGE HIGH
CHURN HIGH
DESIGN SMELL
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
TESTING NOT A FOCUS
@mscottford
COMPLEXITY LOW
CODE COVERAGE LOW
CHURN LOW
TESTING NOT A FOCUS
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
REFACTORING NOT A FOCUS
@mscottford
COMPLEXITY HIGH
CODE COVERAGE HIGH
CHURN LOW
REFACTORING NOT A FOCUS
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
UNHEALTHY: LOW PRIORITY
@mscottford
COMPLEXITY HIGH
CODE COVERAGE LOW
CHURN LOW
UNHEALTHY: LOW PRIORITY
@mscottford
COMPLEXITY
CODE COVERAGE
CHURN
UNHEALTHY: HIGH PRIORITY
@mscottford
COMPLEXITY HIGH
CODE COVERAGE LOW
CHURN HIGH
UNHEALTHY: HIGH PRIORITY
@mscottford
QUESTIONS?
@mscottford
CONTACT INFO
@mscottford
@corgibytes
corgibytes.com
LegacyCode.Rocks

Contenu connexe

Similaire à Important metrics for Measuring Code Health

Similaire à Important metrics for Measuring Code Health (10)

Old Code, New Tricks
Old Code, New TricksOld Code, New Tricks
Old Code, New Tricks
 
MenderCon 2020 Keynote Presentation
MenderCon 2020 Keynote PresentationMenderCon 2020 Keynote Presentation
MenderCon 2020 Keynote Presentation
 
A deep dive into measuring dependency freshness with lib year
A deep dive into measuring dependency freshness with lib yearA deep dive into measuring dependency freshness with lib year
A deep dive into measuring dependency freshness with lib year
 
PyGeekle 2022 - A Deep Dive into Measuring Dependency Freshness with LibYear
PyGeekle 2022 - A Deep Dive into Measuring Dependency Freshness with LibYearPyGeekle 2022 - A Deep Dive into Measuring Dependency Freshness with LibYear
PyGeekle 2022 - A Deep Dive into Measuring Dependency Freshness with LibYear
 
Makers and menders - Finding Talent for Legacy Code Projects
Makers and menders - Finding Talent for Legacy Code ProjectsMakers and menders - Finding Talent for Legacy Code Projects
Makers and menders - Finding Talent for Legacy Code Projects
 
Help your scrum team strike oil!
Help your scrum team strike oil!Help your scrum team strike oil!
Help your scrum team strike oil!
 
Algorithm of Reading Scientific Research Article
Algorithm of Reading Scientific Research Article Algorithm of Reading Scientific Research Article
Algorithm of Reading Scientific Research Article
 
Getting the best of Linked Data and Property Graphs: rdf2neo and the KnetMine...
Getting the best of Linked Data and Property Graphs: rdf2neo and the KnetMine...Getting the best of Linked Data and Property Graphs: rdf2neo and the KnetMine...
Getting the best of Linked Data and Property Graphs: rdf2neo and the KnetMine...
 
TW-BERT: Good for Users, Good for SEOs | Dave Cousin, Brighton SEO Deck
TW-BERT: Good for Users, Good for SEOs | Dave Cousin, Brighton SEO DeckTW-BERT: Good for Users, Good for SEOs | Dave Cousin, Brighton SEO Deck
TW-BERT: Good for Users, Good for SEOs | Dave Cousin, Brighton SEO Deck
 
Past and today of Metasepi project
Past and today of Metasepi projectPast and today of Metasepi project
Past and today of Metasepi project
 

Plus de M. Scott Ford

Communication is Just as Important as Code
Communication is Just as Important as CodeCommunication is Just as Important as Code
Communication is Just as Important as Code
M. Scott Ford
 
Building a Bridge to a Legacy Application: How Hard Can That Be?
Building a Bridge to a Legacy Application: How Hard Can That Be?Building a Bridge to a Legacy Application: How Hard Can That Be?
Building a Bridge to a Legacy Application: How Hard Can That Be?
M. Scott Ford
 

Plus de M. Scott Ford (6)

Lessons Learned Migrating from Jekyll to Next.pptx
Lessons Learned Migrating from Jekyll to Next.pptxLessons Learned Migrating from Jekyll to Next.pptx
Lessons Learned Migrating from Jekyll to Next.pptx
 
Communication is Just as Important as Code
Communication is Just as Important as CodeCommunication is Just as Important as Code
Communication is Just as Important as Code
 
MenderCon 2021 - Keynote
MenderCon 2021 - KeynoteMenderCon 2021 - Keynote
MenderCon 2021 - Keynote
 
Moving a Monolith to Kubernetes
Moving a Monolith to KubernetesMoving a Monolith to Kubernetes
Moving a Monolith to Kubernetes
 
Building a Bridge to a Legacy Application: How Hard Can That Be?
Building a Bridge to a Legacy Application: How Hard Can That Be?Building a Bridge to a Legacy Application: How Hard Can That Be?
Building a Bridge to a Legacy Application: How Hard Can That Be?
 
Embracing the Red Bar: A Technique for Safely Refactoring Your Test Suite
Embracing the Red Bar: A Technique for Safely Refactoring Your Test SuiteEmbracing the Red Bar: A Technique for Safely Refactoring Your Test Suite
Embracing the Red Bar: A Technique for Safely Refactoring Your Test Suite
 

Dernier

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Important metrics for Measuring Code Health