We all know PHPTheRightWay.com, right? It’s a site (and book) full of best practices for getting started and generally developing with PHP. We’ve known for a while now that some people just don’t do modern even when exposed to better practices. Some are just too baked into their own past habits to change, but others make a best effort and then simply - misunderstand.
This is how we assume the page PHPTheWrongWay.com came to be. It’s a kind of critique of PHP The Right Way, listing its suggestions and arguing against or “alongside” them, trying to get people to stay from absolutes but, in the end, advising to go almost the opposite route.
This prompted a response from Jon LeMaitre who sums up the site’s shortcomings thusly:
In general, PHP - The Wrong Way delivers three positive fundamental messages: keep things as simple as possible, don’t use/apply tools dogmatically, and write secure software by default. This is generally good advice, except PHP — The Wrong Way expresses much of its advice through a series of gross mischaracterizations of the PHP community, the nature of frameworks, standards, and PHP itself.
Having thoroughly read both “Right” and “Wrong”, I can say that I agree with Jon’s assessment, but I can also say that while there are some aspects of “Wrong” that make a reasonable degree of sense, they would have carried more weight if only the author had considered getting an editor (or several) before publishing - far too many people don’t have people review their content before putting it out, and then it’s full of typos, mistakes, or even worse - factual errors. That’s why peer review is incredibly important.
The part about not going with OOP in particular. Case in point:
Today, one of the main strengths of PHP is its support for both imperative, functional, object-oriented, procedural, and reflective paradigms.
There’s no such thing as a reflective paradigm. What? There’s reflection, but there’s no actual paradigm around it. PHP’s strength being functional programming? Its most powerful debugger, XDebug, has a built in crash mechanism for recursion deeper than 100 levels and requires hacks to get around. That is not a staple of a good functional programming environment. Besides, many of the terms seem to be unclear to the author, and could have been clarified by others if only he had asked around prior to publishing - it all would have made for a much more balanced and well written argument that may actually have benefitted the community.
PHP is a huge toolbox with lots of different tools that makes it possible to solve many problems in many different ways - not just one way!
OOP is not a way to solve a problem. It’s a way to structure the solution to a problem - a way that completely blows most alternatives completely out of the water by allowing for easy unit testing, code resharing, encapsulation, and much more!
Anyway, enough dwelling on this - please read Jon’s post for other counter-arguments to these counter-arguments, and then tell me what you think about the whole ordeal, eh?