Pro Yearly is on sale from $80 to $50! »

Dotting your i’s and crossing your t’s

Dotting your i’s and crossing your t’s

Presented on June 2nd 2016 at the GroningenPHP Meetup, Groningen, The Netherlands.
http://www.meetup.com/GroningenPHP/events/228763161/
---------------------------------------------------------------
Ever had to go back to code you did over a year ago ? And… did you like it ?
We all *love* well documented, testable, easily readable and understandable code. But how do you write it ? and what tools are available to help you ?
What can you do *now* to make your life and the life of your successor(s) and users easier ?
Learn how to avoid a build up of technical debt and make your good code awesome!
---------------------------------------------------------------

If you download the slides, the links should be clickable. Unfortunately they don't seem to be in the online deck, so here's a list of the links:

Slide 2:
Pluralsight: https://www.pluralsight.com/courses/regular-expressions-fundamentals

Slide 10
Technical debt in PHP projects: http://blog.insight.sensiolabs.com/2014/11/04/technical-debt-relevant-projects.html

Slide 11
Types of Technical Debt: http://www.martinfowler.com/bliki/TechnicalDebtQuadrant.html

Slide 12
How Quality affects software costs: http://www.sqgne.org/presentations/2010-11/Jones-Nov-2010.pdf

Slide 14
PHPUnderControl: http://phpundercontrol.org/
Sonar: http://www.sonarsource.com/

Slide 19
PSRs: http://www.php-fig.org/

Slide 20 - Debugging tools:
XDEBUG: http://xdebug.org/
PHP lint: http://www.icosaedro.it/phplint/
JS lint + hint: http://www.jslint.com/ , http://www.javascriptlint.com/ , http://www.jshint.com/
Firebug: http://getfirebug.com/
Profile: https://github.com/joehoyle/Time-Stack

Slide 21 - Educate yourself:
PHP manual: http://php.net/manual
PHP The Right Way: http://phptherightway.com/
ClearPHP: https://github.com/dseguy/clearPHP/blob/master/rules/README.md
phpcheatsheets.com: http://phpcheatsheets.com/
OWASP top 10: http://owasp.org/

Slide 28
PHP Code Sniffer: http://pear.php.net/package/PHP_CodeSniffer/
PHP CS-Fixer: http://cs.sensiolabs.org/

Slide 30
PHP cross-version compatibility ruleset for PHPCS: https://github.com/wimg/PHPCompatibility

Slide 38
PHPDocumentor: http://www.phpdoc.org/
PHPDox: http://phpdox.de/
ApiGen: http://www.apigen.org/

Slide 43
PHPUnit: http://phpunit.de/

Slide 45
Codeception: http://codeception.com/
Behat: http://behat.org/
PHPSpec: http://www.phpspec.net/
Selenium: http://docs.seleniumhq.org/

Slide 48
pDepend: http://pdepend.org/
PHPLOC: https://github.com/sebastianbergmann/phploc

Slide 49
PHP Mess Detector: http://phpmd.org/

Slide 50
PHP Copy Paste Detector: https://github.com/sebastianbergmann/phpcpd

Slide 51
PHP Dead Code Detector: https://github.com/sebastianbergmann/phpdcd

Slide 56
Git hooks: http://git-scm.com/docs/githooks.html and http://git-scm.com/book/en/Customizing-Git-Git-Hooks
Phing: http://www.phing.info/
Robo: http://robo.li/
GrumPHP: https://github.com/phpro/grumphp
Grunt: http://gruntjs.com/
Capistrano: http://capistranorb.com/
Gulp: http://gulpjs.com/

Slide 57:
Sonar: http://www.sonarsource.com/
Jenkins: http://jenkins-ci.org/
Travis: https://travis-ci.org/
Scrutinizer CI: http://scrutinizer-ci.com/
Circle CI: https://circleci.com/
PHP-CI: https://github.com/block8/phpci
Atlassian Bamboo: https://www.atlassian.com/software/bamboo
Exakat: http://www.exakat.io/online-demo/
Codeship: https://codeship.com/

Slide 62
Geek and Poke: http://geek-and-poke.com/
OSNews: http://osnews.com/comics

Slide 63:
Slides - well, you found them already ;-)
Feedback: https://joind.in/18322
Contact me: https://twitter.com/jrf_nl

2776198ea9584b6c0d4b494293b8d635?s=128

Juliette Reinders Folmer

June 02, 2016
Tweet

Transcript

  1. Dotting Your I's and Crossing Your T's How to Make

    Good Code GREAT Juliette Reinders Folmer @jrf_nl
  2. #groningenPHP Who Am I? Self-employed, Independent Consultant Training Author at

    Pluralsight pluralsight.com Contributor to many open source projects
  3. #groningenPHP

  4. #groningenPHP

  5. #groningenPHP

  6. #groningenPHP Properties of Quality Code Maintainable Extensible Re-usable

  7. #groningenPHP

  8. #groningenPHP Potential defects Coding style Documentation Code coverage Code duplication

    Code complexity Unshared knowledge or code Unstable deployment process Outdated third party dependencies Technical Debt
  9. #groningenPHP

  10. #groningenPHP

  11. #groningenPHP Types of Technical Debt Martin Fowler's Quadrant - ©

    Martin Fowler
  12. #groningenPHP Why Bother ? ©2010 Capers Jones & Associates LLC

  13. #groningenPHP Technical debt accumulates interest. Just like financial debt...

  14. #groningenPHP Estimating & Prioritizing  PHPUnderControl  Sonar

  15. Mitigating Technical Debt

  16. #groningenPHP Mitigating  Inventarize & managing  Prioritize  Budget

  17. #groningenPHP

  18. Prevent Bugs

  19. #groningenPHP Prevent Bugs  Apply best practices • APIs •

    Security • Avoid conflict • Lean & mean • Optimize • Apply PSR's
  20. #groningenPHP Prevent Bugs  Apply best practices  Use debugging

    tools • error_reporting() • XDEBUG • PHP lint • JS lint + hint • Firebug + extensions • Profile
  21. #groningenPHP Prevent Bugs  Apply best practices  Use debugging

    tools  Educate yourself • PHP manual • PHP The Right Way • Clear PHP • phpcheatsheets.com • OWASP top 10 • Conferences !
  22. Version

  23. #groningenPHP  CVS  SVN  GIT

  24. #groningenPHP

  25. Style

  26. #groningenPHP

  27. #groningenPHP PHP Coding Standards PSR-1 PSR-2 PEAR Squiz Zend Framework

    Symphony Drupal WordPress TYPO3 Magento CakePHP FuelPHP ....
  28. #groningenPHP PHPCS (PHP Code Sniffer) PHP-CS-Fixer

  29. #groningenPHP

  30. #groningenPHP https://github.com/wimg/PHPCompatibility

  31. #groningenPHP

  32. Document

  33. #groningenPHP

  34. #groningenPHP

  35. #groningenPHP Documenting Your Code /** * Retrieve the (cached) file

    list for path. * * @param string $path * @param bool|null $recursive * @param string|array $allowed_extensions * * @return array|false File list array or false if an invalid path was provided */ public static function get_file_list( $path, $recursive = false, $allowed_extensions = null ) { }
  36. #groningenPHP Documenting Your Code /** * Retrieve the (cached) file

    list for path. * * @todo Check how optimized scandir() is and whether it would be useful to get a list * of all files first and only later filter for allowed extensions / subdirs. * * @since 0.5 * * @uses DirectoryWalker::$cache * @uses DirectoryWalker::validate_exts() * @uses DirectoryWalker::traverse_directory() * * @static * * @param string $path Path to directory. * @param bool|null $recursive Whether or not to walk subdirectories. * @param string|array $allowed_extensions Array of extensions to filter the files on. * * @return array|false File list array or false if an invalid path was provided */ public static function get_file_list( $path, $recursive = false, $allowed_extensions = null ) { }
  37. #groningenPHP

  38. #groningenPHP PHPDocumentor PHPDox ApiGen

  39. #groningenPHP

  40. #groningenPHP

  41. Test

  42. #groningenPHP

  43. #groningenPHP http://phpunit.de/

  44. #groningenPHP

  45. #groningenPHP Codeception Behat PHPSpec Selenium

  46. Analyse & Refactor

  47. #groningenPHP Metrics Code smells Cyclomatic complexity Npath complexity CRAP index

  48. #groningenPHP pDepend PHPLOC

  49. #groningenPHP PHPMD

  50. #groningenPHP PHPCPD (PHP Copy Paste Detector)

  51. #groningenPHP PHPDCD (PHP Dead Code Detector)

  52. #groningenPHP --verbose

  53. #groningenPHP

  54. Automate

  55. #groningenPHP

  56. #groningenPHP  Git hooks  Phing  Robo  GrumPHP

     Grunt  Capistrano  Gulp ... etc...
  57. #groningenPHP  Sonar  Jenkins  Travis  Scrutinizer CI

     Circle CI  PHP-CI  Atlassian Bamboo  Exakat  Codeship ... etc...
  58. Team

  59. #groningenPHP

  60. #groningenPHP

  61. #groningenPHP Always code as if the guy who ends up

    maintaining your code will be a violent psychopath who knows where you live. - Martin Golding O’Reilly “ ”
  62. #groningenPHP Liked the Cartoons ? Also: the WTF Quality cartoon

    by Thom Holwerda – OSNews.com Geek and Poke is a creation of Oliver Widder Cartoons used with gracious CC permission Visit geek-and-poke.com for more !
  63. Thank You! Slides: http://speakerdeck.com/jrf Feedback: https://joind.in/18322 Contact me: @jrf_nl