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 Codejosedasilva
 
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

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 

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