What’s that old saying? Practice doesn’t make perfect. Perfect practice makes perfect? Well tell that to the 90%+ of tutorial authors out there and maybe we can get somewhere.
I’ve been brushing up on this as I haven’t done anything major with PHP since 4.1 (yeah, yeah, I’ve been slow to catch up, so sue me). Come to think of it, I haven’t done anything major with PHP. Just a couple of small CMS’s for personal sites.
I got exactly what I expected. The worst possible programming practices…
– Not checking for SQL injections or querystring hacks.
– No mysqli usage. What version are we using again?
– No OO development. Class? What’s that?
– No data / logic / presentation separation. Because we all enjoy spaghetti.
– No database abstraction MYSQL FOR LIFE!!!11.
– No multilingual capability or UTF data storage. English or GTFO!
– Register globals. Someone seriously needs a spanking.
– Magic quotes. AARRRRGH you nitwits!!
So virtually nothing has changed since I mucked about in 4.1.
The tutorials still suck!
Admittedly, PHP has a number of shortcomings (most of which are currently being solved) that have been the cause of legitimate criticism. But it’s like some of these people didn’t even try to work around them. It’s not the programming language, it’s the programmers.
I’ve seen pre-teens write beautiful code in PHP and middle-aged failed businessmen write Kligon… in brackets.
PHP Gets a very bad rap because a large number of projects out there are complete rubbish. But the blame doesn’t rest solely on the programmers. I think tutorial authors share much of it. How can novice programmers be expected to write any worthwhile code, when the examples are equally worthless?
You reap what you sow!
Pingback: Cross Site Scripting » Blog Archive » Top 25 Most Dangerous Programming Errors
I’ve found that books on PHP or projects bulit in PHP (Drupal, Joomla!, etc) show much, much better design and implementation methodologies than do the tutorials you find on the web. Granted, the tutorials can help you figure out how to do that one specific thing you can’t quite get working correctly, but you then need to be a good programmer and figure out how that will fit into good practice.
Working on Joomla! taught me a hell of a lot about how a complex application can be built in a very robust, elegant way. Working on phpBB (back during the 2.0.x branch; haven’t looked under the 3.0.x hood yet) taught me a hell of a lot about how to NOT write complex applications. As it becomes more and more mainstream, I suspect the tutorial quality will improve as well.
That’s one more thing I forgot to mention.
It seems the only way for people to really get into good PHP practices is to take apart a sucessful application and go through it line by line. A friend got me a “PHP for Dummies” book (LOL) and the example provided turned out to be Mambo… er… all is forgiven between you guys by now right? ;)
But, with phpBB, it’s one of those apps where people actually give up learning PHP. I’m virtually convinced that a significant portion of programmers look at the 2.0 source and go “the hell with this!”
I haven’t looked at 3 either, but hopefully they’ve left behind a ton of cruft.
The Catch 22 is that for PHP to become more mainstream, it has to have better examples and more comprehensive tutorials. But better tutorials will only come when it becomes more mainstream.
Web tutorials are really the best way to ensure adoption as people are more likely to study online than with a book. Even if the print media is excellent by comparison.
Meanwhile, languages like Ruby and Python are taking off. So this can’t wait any longer. We need good, comprehensive, web tutorials now!
So how do we do this? No commitment. just brainstorming and let see how far we go from here.
Who is the target reader/learner/follower to the ideal tutorial you have in mind?
Prior to taking the tutorial the reader/learner/follower should have hours of experience installing, configuring, Apache/IIS web server with PHP, MySQL, PhpMyAdmin is a must have experience.
I am interested with the concept because I never learn how it is to learn from scratch in the internet. I always learn by reading the books from introduction to the last page.
The problem I encountered while learning PHP and MySQL is rudimentary. The exercise from the books just did not work. I spent reading line by line of code between the book and my computer screen. man! at the end I have to go to the almighty internet until I realize that there is already an existing application. All I have to do is install. What? But the point is I want to learn the language because by knowing and learning PHP and MySQL who knows maybe I can be a developer of plug-ins, components, and projects in Google or Joomla or Drupal.
Thanks for starting the concept.
“The exercise from the books just did not work.”
AH! I know exactly why it didn’t work.
Somewhere along the line, some setting or requirement was off. Of course the book in question didn’t give one very important detail so the whole thing doesn’t work.
This is the big issue with programming. It only takes one wrong character or setting (and it could be pages above) that shows up many steps below.
The only solution is to increment little by little and test each portion independently.
Write line of code > Test
Write line of code > Test
Write line of code > Test
And so on…
This way, if something doesn’t work, you know for sure it was the step before. It’s easier (and quicker) to find out what went wrong and where.
You don’t see a lot of examples that teach like this. Which is one more reason we need better tutorial authors.
The “levels” should really be goals.
And by that I mean, a site admin, a student, a teacher, a band manager, a blogger, and so on.
Your “role”, so to speak, should be the “level”. This way you get to learn what it is you set out to learn instead of being taught things that take you away from your role.
A blogger really doesn’t need to know about forums and stuff because, chances are, it’s just to publish content.
Requirements might be things like simplicity, themes, and feedback from readers (simple comments).
On the other hand, a band manager would want to know about forums, email forms, as well as feedback from readers. So the requirement is slightly more advanced.
Now all these roles, of course, will share common information like security best practices, but the role should dictate where the lessons will go. The person learns PHP on the road to fulfilling the role.
me too I’ve seen children write better code than adults lol …
You know what it is… kids tend to experiment a lot.
They’re also more likely to question “why do it like that instead of this?” Which can, sometimes, lead to better results.
So kids accidentally become better programmers in the process.
Or they turn into script kiddies. :P
If left alone without adult supervision.
Ah, yes… er… well that too ;)