SlideShare a Scribd company logo
Does Your Code
Measure Up?
By:
Adam Culp
Twitter: @adamculp
3
Does Your Code Measure Up?
●
Fan of iteration
– Pretty much everything requires iteration to do well:
●
Long distance running
●
Judo
●
Development
●
Evading project managers
●
Code Quality!
4
Does Your Code Measure Up?
●
How To Measure?
– Not productive
5
Does Your Code Measure Up?
●
Bad Music
– Not a song writer
6
Does Your Code Measure Up?
●
How To Measure?
– More accurate, quantifiable
7
Does Your Code Measure Up?
●
Why Measure?
– Highlight bugs
8
Does Your Code Measure Up?
●
Why Measure?
– Highlight bugs
– Improve quality
●
Easier onboarding
●
Less reading, more writing
●
Testable
9
Does Your Code Measure Up?
●
Why Measure?
– Highlight bugs
– Improve quality
●
Easier onboarding
●
Less reading, more writing
●
Testable
– Satisfied customers
●
Faster development
●
Less broken
10
Does Your Code Measure Up?
●
Why Measure?
– Highlight bugs
– Improve quality
●
Easier onboarding
●
Less reading, more writing
●
Testable
– Satisfied customers
●
Faster development
●
Less broken
– Personal pride
11
Does Your Code Measure Up?
●
Why Measure?
– Highlight bugs
– Improve quality
●
Easier onboarding
●
Less reading, more writing
●
Testable
– Satisfied customers
●
Faster development
●
Less broken
– Personal pride
– Higher salary
12
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
●
“The count of the number of linearly independent paths through the
source code.” - wikipedia
●
Decision points
●
Less than 10 (personally less than 6)
13
Does Your Code Measure Up?
●
Cyclomatic Complexity Example
14
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
●
Rule of 3
15
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
●
Less than 1,000 lines
●
Classes solve a (1) problem
16
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class Complexity
●
Less than 50
17
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class complexity
– Long methods
●
Less than 100 (personally less than 20)
●
Method should do one thing
18
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class complexity
– Long methods
– Unused variables
19
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class complexity
– Long methods
– Unused variables
– Lack or overuse of comments
●
Clear, concise, not explain bad code
20
Does Your Code Measure Up?
●
Comment Example
21
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class complexity
– Long methods
– Unused variables
– Lack or overuse of comments
– Heavy global usage
22
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class complexity
– Long methods
– Unused variables
– Lack or overuse of comments
– Heavy global usage
– Npath complexity
●
Possible paths through code
●
Less than 200 paths
23
Does Your Code Measure Up?
●
What To Measure?
– Cyclomatic complexity
– Duplicate code
– Long classes
– Class complexity
– Long methods
– Unused variables
– Lack or overuse of comments
– Heavy global usage
– Npath complexity
– Much, much, more
●
Code smells
24
Does Your Code Measure Up?
●
Code “smells”
– What are “smells”?
●
Indications of spoiled code nearby
●
Not conclusive
●
The “smell” is not bad
25
Does Your Code Measure Up?
●
Common Code “smells”
– “Smells” hinting a refactor may be needed:
●
Duplicate Code (rule of 3)
●
Long Methods
●
Large Class
●
Long Parameter (argument) List
●
Switch Statements – sacrifice polymorphism
●
Temporary Field/Variable
●
Comments – where comments cover bad code
26
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
27
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
– https://github.com/exakat/php-static-analysis-tools
28
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
●
PHPLoc
29
Does Your Code Measure Up?
●
PHPLoc Results
30
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
●
PHPLoc
●
PHP_Depend - https://pdepend.org/
31
Does Your Code Measure Up?
●
PHP_Depend Result
– Graphs and XML output
ANDC
AHH
NOP
NOC
NOM
LOC
CYCLO
NOM
CALLS
FANOUT9891
96646
66812
395815
23359
342
3192
0.585
0.442
9.333
7.318
16.945
0.169 0.102
4.137
Generated by PHP_DependLow Average High
32
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
●
PHPLoc
●
PHP_Depend
●
PHP Copy/Paste Detector
33
Does Your Code Measure Up?
●
PHP Copy/Paste Detector Result
34
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
●
PHPLoc
●
PHP_Depend
●
PHP Copy/Paste Detector
●
PHP Mess Detector
– Codesize
35
Does Your Code Measure Up?
●
PHP Mess Detector Result (codesize)
36
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
●
PHPLoc
●
PHP_Depend
●
PHP Copy/Paste Detector
●
PHP Mess Detector
– Codesize
– Unused
37
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
●
PHPLoc
●
PHP_Depend
●
PHP Copy/Paste Detector
●
PHP Mess Detector
– Codesize
– Unused
●
PHP Dead Code Detector
– Searches for code no longer used
38
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
– PHPMetrics
●
http://phpmetrics.org
39
Does Your Code Measure Up?
●
PHPMetrics Results
40
Does Your Code Measure Up?
●
Tools
– PHPqatools.org – DEPRECATED
– PHPMetrics
– PHP_Codesniffer
●
Create rules/sniffs to ensure standards are followed
●
From CLI, IDE, or via SCM hooks
41
Does Your Code Measure Up?
●
Containerized Tools
– PHPLoc
– PHPDepend
– PHPMessDetector
– PHPCopyPasteDetector
– PHPMetrics
– PHP_Codesniffer
https://github.com/adamculp/php-code-quality
https://hub.docker.com/u/adamculp/
42
Does Your Code Measure Up?
●
Docker Hub
https://hub.docker.com/u/adamculp/
43
Does Your Code Measure Up?
●
Commercial Tools
– Code Climate
●
Build from Git/Github repo
– Open = free
– Private = $
●
GPA – like in high school, simple
44
Does Your Code Measure Up?
●
Commercial Tools
– Code Climate
– Scrutinizer
45
Does Your Code Measure Up?
●
Commercial Tools
– Code Climate
– Scrutinizer
– Zend Server and Z-Ray
●
Debugging, Code tracing, Error reporting
46
Does Your Code Measure Up?
●
Performance Tools
– Apache Bench (apache2-utils in apt)
●
How much traffic can you handle?
47
Does Your Code Measure Up?
●
Apache Bench Result
48
Does Your Code Measure Up?
●
Realtime profiling
– Z-Ray
49
Does Your Code Measure Up?
●
Conclusion
– Measure all the things!
– Don't fear results, share them
– Reduce complexity
– Leave code cleaner than you got it
– Learn to “smell” problems
– Use refactoring to fix shortcomings
– Love iteration!
50
●
Thank you!
– http://phpqatools.org https://github.com/exakat/php-static-analysis-tools
– http://phpmetrics.org
– https://github.com/adamculp/php-code-quality
– http://zend.com
– http://codeclimate.com
– Please rate
Adam Culp
http://www.geekyboy.com
http://RunGeekRadio.com
Twitter @adamculp

More Related Content

What's hot

Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
Peter Kofler
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
Peter Kofler
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
Peter Kofler
 
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Peter Kofler
 
Java User Groups in Austria (2013)
Java User Groups in Austria (2013)Java User Groups in Austria (2013)
Java User Groups in Austria (2013)
Peter Kofler
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
Peter Kofler
 
Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)
Peter Kofler
 
Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)
Peter Kofler
 
Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
Peter Kofler
 
TDD as if You Meant It (2013)
TDD as if You Meant It (2013)TDD as if You Meant It (2013)
TDD as if You Meant It (2013)
Peter Kofler
 
Outside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDDOutside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDD
Peter Kofler
 
Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)
Peter Kofler
 
AgilePT2012 PGMADS
AgilePT2012 PGMADSAgilePT2012 PGMADS
AgilePT2012 PGMADS
Catarina Reis
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
Peter Kofler
 
The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)
Peter Kofler
 
Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)
Peter Kofler
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
Peter Kofler
 
Mob Programming (2016)
Mob Programming (2016)Mob Programming (2016)
Mob Programming (2016)
Peter Kofler
 
Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)
Peter Kofler
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 

What's hot (20)

Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
 
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
 
Java User Groups in Austria (2013)
Java User Groups in Austria (2013)Java User Groups in Austria (2013)
Java User Groups in Austria (2013)
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
 
Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)
 
Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)
 
Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
 
TDD as if You Meant It (2013)
TDD as if You Meant It (2013)TDD as if You Meant It (2013)
TDD as if You Meant It (2013)
 
Outside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDDOutside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDD
 
Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)
 
AgilePT2012 PGMADS
AgilePT2012 PGMADSAgilePT2012 PGMADS
AgilePT2012 PGMADS
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
 
The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)
 
Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)Clean Readable Specifications (ETC 2016)
Clean Readable Specifications (ETC 2016)
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
 
Mob Programming (2016)
Mob Programming (2016)Mob Programming (2016)
Mob Programming (2016)
 
Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 

Viewers also liked

Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing Development
Adam Culp
 
Accidental professional
Accidental professionalAccidental professional
Accidental professional
Adam Culp
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
Adam Culp
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
Adam Culp
 
Expressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffExpressive Microservice Framework Blastoff
Expressive Microservice Framework Blastoff
Adam Culp
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
Adam Culp
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
Adam Culp
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101
Adam Culp
 

Viewers also liked (8)

Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing Development
 
Accidental professional
Accidental professionalAccidental professional
Accidental professional
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
 
Expressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffExpressive Microservice Framework Blastoff
Expressive Microservice Framework Blastoff
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101
 

Similar to Does Your Code Measure Up?

Containing Quality
Containing QualityContaining Quality
Containing Quality
Adam Culp
 
Code quality and its business value, Nikita Belov
Code quality and its business value, Nikita BelovCode quality and its business value, Nikita Belov
Code quality and its business value, Nikita Belov
CzechDreamin
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Code
josedasilva
 
Journey to Google
Journey to GoogleJourney to Google
Journey to Google
GDSC PJATK
 
Code Reviews in Python - PyZh
Code Reviews in Python - PyZhCode Reviews in Python - PyZh
Code Reviews in Python - PyZh
Cesar Cardenas Desales
 
Clean application development (talk)
Clean application development (talk)Clean application development (talk)
Clean application development (talk)
Adam Culp
 
DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...
DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...
DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...
Gene Kim
 
Mirco hering devops for systems of record final
Mirco hering devops for systems of record finalMirco hering devops for systems of record final
Mirco hering devops for systems of record final
Mirco Hering
 
Linters for frontend code review
Linters for frontend code reviewLinters for frontend code review
Linters for frontend code review
Vsevolod Nechaev
 
Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity
Peter Gfader
 
Clean application development tutorial
Clean application development tutorialClean application development tutorial
Clean application development tutorial
Adam Culp
 
Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical Debt
Adam Culp
 
Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)
Peter Kofler
 
Code Review
Code ReviewCode Review
Code Review
Lukas Rypl
 
Improve existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit testsImprove existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit tests
Dattatray Kale
 
How to quickly add a safety net to a legacy codebase
How to quickly add a safety net to a legacy codebaseHow to quickly add a safety net to a legacy codebase
How to quickly add a safety net to a legacy codebase
Nelis Boucké
 
PHP Code Quality
PHP Code QualityPHP Code Quality
PHP Code Quality
Usman Zafar
 
Coding Dojo: String Calculator (2013)
Coding Dojo: String Calculator (2013)Coding Dojo: String Calculator (2013)
Coding Dojo: String Calculator (2013)
Peter Kofler
 
You cant be agile if your code sucks
You cant be agile if your code sucksYou cant be agile if your code sucks
You cant be agile if your code sucks
Peter Gfader
 
Refactoring code in .net
Refactoring code in .netRefactoring code in .net
Refactoring code in .net
Tung Nguyen Thanh
 

Similar to Does Your Code Measure Up? (20)

Containing Quality
Containing QualityContaining Quality
Containing Quality
 
Code quality and its business value, Nikita Belov
Code quality and its business value, Nikita BelovCode quality and its business value, Nikita Belov
Code quality and its business value, Nikita Belov
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Code
 
Journey to Google
Journey to GoogleJourney to Google
Journey to Google
 
Code Reviews in Python - PyZh
Code Reviews in Python - PyZhCode Reviews in Python - PyZh
Code Reviews in Python - PyZh
 
Clean application development (talk)
Clean application development (talk)Clean application development (talk)
Clean application development (talk)
 
DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...
DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...
DOES15 - Mirco Hering - Adopting DevOps Practices for Systems of Record – An ...
 
Mirco hering devops for systems of record final
Mirco hering devops for systems of record finalMirco hering devops for systems of record final
Mirco hering devops for systems of record final
 
Linters for frontend code review
Linters for frontend code reviewLinters for frontend code review
Linters for frontend code review
 
Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity
 
Clean application development tutorial
Clean application development tutorialClean application development tutorial
Clean application development tutorial
 
Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical Debt
 
Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)
 
Code Review
Code ReviewCode Review
Code Review
 
Improve existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit testsImprove existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit tests
 
How to quickly add a safety net to a legacy codebase
How to quickly add a safety net to a legacy codebaseHow to quickly add a safety net to a legacy codebase
How to quickly add a safety net to a legacy codebase
 
PHP Code Quality
PHP Code QualityPHP Code Quality
PHP Code Quality
 
Coding Dojo: String Calculator (2013)
Coding Dojo: String Calculator (2013)Coding Dojo: String Calculator (2013)
Coding Dojo: String Calculator (2013)
 
You cant be agile if your code sucks
You cant be agile if your code sucksYou cant be agile if your code sucks
You cant be agile if your code sucks
 
Refactoring code in .net
Refactoring code in .netRefactoring code in .net
Refactoring code in .net
 

More from Adam Culp

Hypermedia
HypermediaHypermedia
Hypermedia
Adam Culp
 
Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middleware
Adam Culp
 
php-1701-a
php-1701-aphp-1701-a
php-1701-a
Adam Culp
 
Release your refactoring superpower
Release your refactoring superpowerRelease your refactoring superpower
Release your refactoring superpower
Adam Culp
 
Developing PHP Applications Faster
Developing PHP Applications FasterDeveloping PHP Applications Faster
Developing PHP Applications Faster
Adam Culp
 
Debugging elephpants
Debugging elephpantsDebugging elephpants
Debugging elephpants
Adam Culp
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Adam Culp
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
Adam Culp
 
Using an API
Using an APIUsing an API
Using an API
Adam Culp
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
Adam Culp
 
Refactoring PHP
Refactoring PHPRefactoring PHP
Refactoring PHP
Adam Culp
 
Selenium testing IDE 101
Selenium testing IDE 101Selenium testing IDE 101
Selenium testing IDE 101
Adam Culp
 
Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3
Adam Culp
 
Development Environment Tips
Development Environment TipsDevelopment Environment Tips
Development Environment Tips
Adam Culp
 
Getting your project_started
Getting your project_startedGetting your project_started
Getting your project_started
Adam Culp
 
PHP and PDFLib
PHP and PDFLibPHP and PDFLib
PHP and PDFLib
Adam Culp
 

More from Adam Culp (17)

Hypermedia
HypermediaHypermedia
Hypermedia
 
Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middleware
 
php-1701-a
php-1701-aphp-1701-a
php-1701-a
 
Release your refactoring superpower
Release your refactoring superpowerRelease your refactoring superpower
Release your refactoring superpower
 
Developing PHP Applications Faster
Developing PHP Applications FasterDeveloping PHP Applications Faster
Developing PHP Applications Faster
 
Debugging elephpants
Debugging elephpantsDebugging elephpants
Debugging elephpants
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
 
Using an API
Using an APIUsing an API
Using an API
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
 
Refactoring PHP
Refactoring PHPRefactoring PHP
Refactoring PHP
 
Selenium testing IDE 101
Selenium testing IDE 101Selenium testing IDE 101
Selenium testing IDE 101
 
Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3
 
Development Environment Tips
Development Environment TipsDevelopment Environment Tips
Development Environment Tips
 
Getting your project_started
Getting your project_startedGetting your project_started
Getting your project_started
 
PHP and PDFLib
PHP and PDFLibPHP and PDFLib
PHP and PDFLib
 

Recently uploaded

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
CAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on BlockchainCAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on Blockchain
Claudio Di Ciccio
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
CAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on BlockchainCAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on Blockchain
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 

Does Your Code Measure Up?

  • 1. Does Your Code Measure Up? By: Adam Culp Twitter: @adamculp
  • 2. 3 Does Your Code Measure Up? ● Fan of iteration – Pretty much everything requires iteration to do well: ● Long distance running ● Judo ● Development ● Evading project managers ● Code Quality!
  • 3. 4 Does Your Code Measure Up? ● How To Measure? – Not productive
  • 4. 5 Does Your Code Measure Up? ● Bad Music – Not a song writer
  • 5. 6 Does Your Code Measure Up? ● How To Measure? – More accurate, quantifiable
  • 6. 7 Does Your Code Measure Up? ● Why Measure? – Highlight bugs
  • 7. 8 Does Your Code Measure Up? ● Why Measure? – Highlight bugs – Improve quality ● Easier onboarding ● Less reading, more writing ● Testable
  • 8. 9 Does Your Code Measure Up? ● Why Measure? – Highlight bugs – Improve quality ● Easier onboarding ● Less reading, more writing ● Testable – Satisfied customers ● Faster development ● Less broken
  • 9. 10 Does Your Code Measure Up? ● Why Measure? – Highlight bugs – Improve quality ● Easier onboarding ● Less reading, more writing ● Testable – Satisfied customers ● Faster development ● Less broken – Personal pride
  • 10. 11 Does Your Code Measure Up? ● Why Measure? – Highlight bugs – Improve quality ● Easier onboarding ● Less reading, more writing ● Testable – Satisfied customers ● Faster development ● Less broken – Personal pride – Higher salary
  • 11. 12 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity ● “The count of the number of linearly independent paths through the source code.” - wikipedia ● Decision points ● Less than 10 (personally less than 6)
  • 12. 13 Does Your Code Measure Up? ● Cyclomatic Complexity Example
  • 13. 14 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code ● Rule of 3
  • 14. 15 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes ● Less than 1,000 lines ● Classes solve a (1) problem
  • 15. 16 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class Complexity ● Less than 50
  • 16. 17 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class complexity – Long methods ● Less than 100 (personally less than 20) ● Method should do one thing
  • 17. 18 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class complexity – Long methods – Unused variables
  • 18. 19 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class complexity – Long methods – Unused variables – Lack or overuse of comments ● Clear, concise, not explain bad code
  • 19. 20 Does Your Code Measure Up? ● Comment Example
  • 20. 21 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class complexity – Long methods – Unused variables – Lack or overuse of comments – Heavy global usage
  • 21. 22 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class complexity – Long methods – Unused variables – Lack or overuse of comments – Heavy global usage – Npath complexity ● Possible paths through code ● Less than 200 paths
  • 22. 23 Does Your Code Measure Up? ● What To Measure? – Cyclomatic complexity – Duplicate code – Long classes – Class complexity – Long methods – Unused variables – Lack or overuse of comments – Heavy global usage – Npath complexity – Much, much, more ● Code smells
  • 23. 24 Does Your Code Measure Up? ● Code “smells” – What are “smells”? ● Indications of spoiled code nearby ● Not conclusive ● The “smell” is not bad
  • 24. 25 Does Your Code Measure Up? ● Common Code “smells” – “Smells” hinting a refactor may be needed: ● Duplicate Code (rule of 3) ● Long Methods ● Large Class ● Long Parameter (argument) List ● Switch Statements – sacrifice polymorphism ● Temporary Field/Variable ● Comments – where comments cover bad code
  • 25. 26 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED
  • 26. 27 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED – https://github.com/exakat/php-static-analysis-tools
  • 27. 28 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED ● PHPLoc
  • 28. 29 Does Your Code Measure Up? ● PHPLoc Results
  • 29. 30 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED ● PHPLoc ● PHP_Depend - https://pdepend.org/
  • 30. 31 Does Your Code Measure Up? ● PHP_Depend Result – Graphs and XML output ANDC AHH NOP NOC NOM LOC CYCLO NOM CALLS FANOUT9891 96646 66812 395815 23359 342 3192 0.585 0.442 9.333 7.318 16.945 0.169 0.102 4.137 Generated by PHP_DependLow Average High
  • 31. 32 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED ● PHPLoc ● PHP_Depend ● PHP Copy/Paste Detector
  • 32. 33 Does Your Code Measure Up? ● PHP Copy/Paste Detector Result
  • 33. 34 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED ● PHPLoc ● PHP_Depend ● PHP Copy/Paste Detector ● PHP Mess Detector – Codesize
  • 34. 35 Does Your Code Measure Up? ● PHP Mess Detector Result (codesize)
  • 35. 36 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED ● PHPLoc ● PHP_Depend ● PHP Copy/Paste Detector ● PHP Mess Detector – Codesize – Unused
  • 36. 37 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED ● PHPLoc ● PHP_Depend ● PHP Copy/Paste Detector ● PHP Mess Detector – Codesize – Unused ● PHP Dead Code Detector – Searches for code no longer used
  • 37. 38 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED – PHPMetrics ● http://phpmetrics.org
  • 38. 39 Does Your Code Measure Up? ● PHPMetrics Results
  • 39. 40 Does Your Code Measure Up? ● Tools – PHPqatools.org – DEPRECATED – PHPMetrics – PHP_Codesniffer ● Create rules/sniffs to ensure standards are followed ● From CLI, IDE, or via SCM hooks
  • 40. 41 Does Your Code Measure Up? ● Containerized Tools – PHPLoc – PHPDepend – PHPMessDetector – PHPCopyPasteDetector – PHPMetrics – PHP_Codesniffer https://github.com/adamculp/php-code-quality https://hub.docker.com/u/adamculp/
  • 41. 42 Does Your Code Measure Up? ● Docker Hub https://hub.docker.com/u/adamculp/
  • 42. 43 Does Your Code Measure Up? ● Commercial Tools – Code Climate ● Build from Git/Github repo – Open = free – Private = $ ● GPA – like in high school, simple
  • 43. 44 Does Your Code Measure Up? ● Commercial Tools – Code Climate – Scrutinizer
  • 44. 45 Does Your Code Measure Up? ● Commercial Tools – Code Climate – Scrutinizer – Zend Server and Z-Ray ● Debugging, Code tracing, Error reporting
  • 45. 46 Does Your Code Measure Up? ● Performance Tools – Apache Bench (apache2-utils in apt) ● How much traffic can you handle?
  • 46. 47 Does Your Code Measure Up? ● Apache Bench Result
  • 47. 48 Does Your Code Measure Up? ● Realtime profiling – Z-Ray
  • 48. 49 Does Your Code Measure Up? ● Conclusion – Measure all the things! – Don't fear results, share them – Reduce complexity – Leave code cleaner than you got it – Learn to “smell” problems – Use refactoring to fix shortcomings – Love iteration!
  • 49. 50 ● Thank you! – http://phpqatools.org https://github.com/exakat/php-static-analysis-tools – http://phpmetrics.org – https://github.com/adamculp/php-code-quality – http://zend.com – http://codeclimate.com – Please rate Adam Culp http://www.geekyboy.com http://RunGeekRadio.com Twitter @adamculp