/dev/null

Elite is stupid. Back to the roots.

September 15, 2008

ZendCon: Best Practices

Tags: , , , , — 19:19

I found three useful ideas in the PHP Developer Best Practices tutorial by Matthew Weier O’Phinney (Zend Technologies, Ltd.), Mike Naberezny (Maintainable Software):

  • Add something like PHP_CodeSniffer to pre-commit in Subversion to reject code that doesn’t follow standards
  • Run tests in a Subversion post-commit script
  • Try to switch to git, because you can also do commits when offline

Sadly, there were also less good ideas like

  • Prefix private/protected class methods and properties with an underscore (makes refactoring very difficult; instead you should start with all properties being protected anyway and only make properties public, that need to be public)
  • Limit line length to 85 chars (120 chars are ok – nobody uses a 80 char text console for coding anymore – wide screens are standard, even for developers)
  • Use PHP_CodeSniffer (I like ZendCodeAnalyzer)

Look at this, if you wanna see bad practices:

Powered by PHP, Memcached, Suhosin, MySQL and WordPress