Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dotting your i's and crossing your t's - how to make good code great

Dotting your i's and crossing your t's - how to make good code great

Presented on June 9th 2015 at the International PHP Conference, Berlin, Germany.
https://phpconference.com/2015se/en
---------------------------------------------------------------
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!

2776198ea9584b6c0d4b494293b8d635?s=128

Juliette Reinders Folmer

June 09, 2015
Tweet

More Decks by Juliette Reinders Folmer

Other Decks in Programming

Transcript

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

    Good Code GREAT Juliette Reinders Folmer IPC Spring 2015 @jrf_nl
  2. #ipc15 Who am I? Self-employed independent consultant 15+ years in

    IT and web development Zend Certified Engineer PHPCheatsheets.com Contributor to LimeSurvey, phpBB, WordPress, AdoDB, ClearPHP and more
  3. #ipc15

  4. #ipc15

  5. #ipc15

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

  7. #ipc15

  8. #ipc15 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. #ipc15

  10. #ipc15 Types of Technical Debt Martin Fowler's Quadrant - ©

    Martin Fowler
  11. #ipc15 Why bother ? ©2010 Capers Jones & Associates LLC

  12. #ipc15 Estimating & Prioritizing PHPUnderControl Sonar

  13. #ipc15 Mitigating Technical Debt

  14. #ipc15 Mitigating Inventarize & managing Prioritize Budget

  15. #ipc15

  16. #ipc15 Prevent bugs

  17. #ipc15 Prevent Bugs Apply best practices • APIs • Security

    • Avoid conflict • Lean & mean • Optimize • Apply PSR's
  18. #ipc15 Prevent Bugs Apply best practices Use debugging tools •

    error_reporting() • XDEBUG • PHP lint • JS lint + hint • Firebug + extensions • Profile
  19. #ipc15 Prevent Bugs Apply best practices Use debugging tools Educate

    yourself • PHP manual • PHP The Right Way • Clear PHP • phpcheatsheets.com • OWASP top 10 • Conferences !
  20. #ipc15 Version

  21. #ipc15 CVS SVN GIT

  22. #ipc15 Style

  23. #ipc15

  24. #ipc15 PHP Coding Standards PSR-1 PSR-2 PEAR Squiz Zend Framework

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

  26. #ipc15

  27. #ipc15 https://github.com/wimg/PHPCompatibility

  28. #ipc15

  29. #ipc15 Document

  30. #ipc15

  31. #ipc15

  32. #ipc15 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 ) { }
  33. #ipc15 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 ) { }
  34. #ipc15

  35. #ipc15 PHPDocumentor PHPDox ApiGen

  36. #ipc15

  37. #ipc15

  38. #ipc15 Test

  39. #ipc15

  40. #ipc15 http://phpunit.de/

  41. #ipc15

  42. #ipc15 Codeception Behat Selenium

  43. #ipc15 Analyse & Refactor

  44. #ipc15 Metrics Code smells Cyclomatic complexity Npath complexity CRAP index

  45. #ipc15 pDepend PHPLOC

  46. #ipc15 PHPMD

  47. #ipc15 PHPCPD (PHP Copy Paste Detector)

  48. #ipc15 PHPDCD (PHP Dead Code Detector)

  49. #ipc15 --verbose

  50. #ipc15

  51. #ipc15 Automate

  52. #ipc15

  53. #ipc15 Git hooks Phing Grunt Capistrano Gulp ... etc...

  54. #ipc15 Sonar Jenkins Travis Scrutinizer CI Circle CI PHP-CI Atlassian

    Bamboo Exakat ... etc...
  55. #ipc15 Team

  56. #ipc15

  57. #ipc15

  58. #ipc15 Liked the cartoons ? Exception: 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 !
  59. #ipc15 Keep in touch! (I’m self-employed, you can hire me

    ;-) ) Juliette Reinders Folmer LinkedIn: http://nl.linkedin.com/in/julietterf Twitter: http://twitter.com/jrf_nl GitHub: http://github.com/jrfnl/ Slides will be posted to http://speakerdeck.com/jrf
  60. Thank you!