PHP Has No Culture of Testing
Charles Nutter, a Sun engineer who has worked on the JRuby project, commented on PHP in a panel discussion at Sun's CommunityOne conference.
I will not join the "PHP vs. Ruby on Rails" "discussion" here, as the comparison of a programming language to a web application framework for another language does not make sense, IMHO. Instead, I would like to comment on two of Charles Nutter's points.
"With PHP, everyone has his or her own way of doing applications."
I think it is a good thing that the PHP community has a rich offering of framework solutions to choose from.
Although it looks like everyone and their mother is standardizing their PHP-based web application development using the Zend Framework, other component libraries such as the eZ Components and web application frameworks inspired by Ruby on Rails such as Symfony or CakePHP are thriving.
"Testing and tried-and-true design patterns are not part of PHP culture."
Yes, testing has become mainstream / popular thanks to JUnit and the Java community.
Yes, the fact that Ruby on Rails encourages test-driven development is a good thing.
Maybe it took the PHP community a little longer to realize the importance of testing. But now that we know how to build applications that "just work", are fast and scalable, as well as secure, a big topic in the PHP community right now is to implement processes and use techniques that help us assure that the software works correctly throughout the its lifecycle.
As for design patterns: Too many PHP developers are blindly using the GoF Design Patterns in PHP, even when they are not applicable. We have our own design patterns and idioms, though. Things that have no name help developers every day to write scalable code that just works.
10/05/2008 at 10:43 Permalink
Reply
10/05/2008 at 12:52 Permalink
Reply
10/05/2008 at 14:21 Permalink
See, unit testing often means you have to have a way of mocking interfaces, which often leads to cleaner, more separated (and often consequently, more extensible) code.
I mean, that's just a simple example. But it's a big reason that PHP is so heavily frowned upon by larger companies here in Australia - "it's just not professional". And, to a large extent, I agree. But that's for another day.
Reply
10/05/2008 at 15:07 Permalink
It is getting better, though. The eZ Components and Zend Framework are just two examples of projects that consequently use unit tests to assure the quality and improve the design of their code.
Reply
11/05/2008 at 00:19 Permalink
I completely agree with "With PHP, everyone has his or her own way of doing applications.".
And, that sucks as a library-writer too, because it makes it difficult to expect certain components to exist. Like, if I knew Zend would always be around, I can depend on its caching classes; However, this is rarely the case so I end up writing all code completely independent from any PHP library, and only depend on certain PHP (c-)modules to be around.
Reply
11/05/2008 at 19:51 Permalink
Reply
14/05/2008 at 18:15 Permalink
Thanks for this statement, Sebastian.
BTW: In our current Project (all PHP) we have over 400 Tests (Selenium and Unit) and code coverage (lines) > 75%
Test Culture is here!
Reply
20/05/2008 at 10:16 Permalink
Zend Studio still seems buggy and not worth the price tag (at least from what I read on their mailing list) and PDT seems to be the only alternative.
The GoF patterns are a great reference but are by no means the be all, however I think that the PHP community needs more experience with patterns. The ones that come to mind stem from PoEAA (Fowler). Especially when MVC is being debated by architects in the Java / C# world, I think the PHP community's slow adoption of patterns has saved them from design and architecture issues that come from someone dictating MVC (or similar catch-all patterns) as a "best practice" for any and every application.
Good summary
Reply