13
Feb
08

5 (More) Ways to be a Better PHP Developer

Akash Mehta recently posted a story to the Developer Tutorials site on 5 Ways to be a Better PHP Developer. I thought all of Akash’s suggestions were good but a little broad and seemed to involve a lot of reading. And while any budding developer will jump at the chance to expand their burgeoning technical library, I thought there were a couple of items we could add to his list.

1. Start a project that other people (developers and end users) will use.

Nothing will earn you respect (or disdain) faster than writing software for strangers that have to use your code.

Whether it’s a web app for end users, a PEAR extension for developers, or a Wordpress plugin for bloggers, putting software into people’s hands so they can respond to it is the single best thing you can do to become a better programmer. Being put in the position of meeting the demands of your users is valuable in the same way that working as a journalist at a newspaper is. As anyone that has done it will tell you, it’s not easy but once you’ve mastered it you can write under pressure, under deadline, and under brutal public (and editorial) opinion. Writing software isn’t all that different.

Do the work, put it out there and see what comes back. It’s this feedback loop that creates great software and great programmers. And ultimately may be the only feedback that’s worth anything.

2. Learn another language.

If you’re just starting out with PHP this may not be the time to dive into something new, but if you know the language and are just trying trying to improve your skills there are advantages to not being a language specialist.

For example:

  • Java forces you to learn OOP
  • Ruby on Rails[1] forces you to learn MVC
  • C# forces you to be dependent on autocomplete ;-)

Broadening your horizons a bit gives you the opportunity to see how other languages solve certain problems that maybe wouldn’t be obvious in PHP.

For example, I’m a much better PHP developer for having written 7,500 lines of Ruby on Rails code. Apparently, I’m not the only one.

3. Teach someone PHP.

Nothing makes you learn something so well as teaching it. Any student that is really interested in learning something will challenge you to a greater degree than you will ever challenge yourself.

And it might give you some insight into what it’s like to answer the “What is a variable, again?” question 20 times. ;-)

I recently started teaching my son Python after a 5 year absence from the language. It was an interesting experiment not just in how much I had forgotten about Python but in thinking differently about programming. When you can explain to a 13-year-old why you have to cast integers before you concatenate them to strings in Python and why you don’t in PHP — and they understand it — you will be well on your way to becoming a better programmer.

4. Ask for suggestions not solutions.

If you really want to avoid getting told off on IRC, make sure you’ve beaten up a problem before you ask about it. And when you do ask about it, show the code. If you can demonstrate to everyone that you’ve got some skin in the game they’re going to more interested in helping you.

Phrase your question as “what am I doing wrong here” rather than “will you do my work for me.”

5. Use what you read.

It’s harder to read code than to write it.
– Joel Spolsky’s “…cardinal, fundamental law of programming…

Akash kicked off his list with “Read the manual” and “Browse through some code.” Good advice, but you’re only going to learn a language if you write it. You can’t read 100 great novels and then expect to pound out Tender is the Night in one sitting.

Don’t just browse the code, use it. Crack open CakePHP and look at how they handle form validation. Open up HTML_QuickForm2 and look at how it handles element creation. Look at how Wordpress handles database transactions, then compare that with how Drupal does it.

These are all things your application will probably need to do at some point so you should definitely be looking at how other people are solving the problems you are having. And when appropriate, use the code. You will learn so much more if you have to take a block of existing code and modify it to work in your application than you will from just browsing SVN trunks.

That’s it

That’s my 2 cents. If you have any additions, please feel free to post them in the comments.

[1] Yes, I know Rails is not a language — it’s a framework — let’s not nit pick.


7 Responses to “5 (More) Ways to be a Better PHP Developer”


  1. 1 Akash Mehta Feb 14th, 2008 at 2:18 pm

    Some great suggestions! The teaching note is especially interesting - I’ve found by teaching PHP for the past couple of years I’ve identified gaps both in my knowledge and understanding, which I can then fill in with the wonderful manual :)

    Regarding learning another language, I actually wouldn’t recommend a novice developer try that as they might come to understand the conventions of the next language as true of all languages; I’ve seen it happen many times before, especially with the jump between VB(6/.net) and PHP.

    Would love to hear your thoughts on this - if you’re interested, email me.

  2. 2 Ivo Feb 15th, 2008 at 12:30 am
  3. 3 admin Feb 15th, 2008 at 9:39 am

    @Akash, I agree that jumping into a new language isn’t a wise idea if you’re just starting out with PHP. That said, I think that people tend to put on “language blinders” when they get a little too involved with a single set of tools. I tend to see a lot of a value in diversification — which is why I never seem to achieve expert status on any one thing — and rather like the idea of having a toolbox and not just a hammer. For example, I recently had to programmatically alter an 18MB CSV file that Excel couldn’t open. I could have done it with PHP and fgetcsv() but the 16-character AWK one-liner I wrote seems like a much better solution.

    Do people still write straight-up VB? I used to write VB, back when “compiling” basically meant creating a zip file of VBscript. :-)

    @Ivo, Some really good, practical tips in that list.

  4. 4 Daniel Aug 7th, 2008 at 12:21 pm

    I read similar article also named re) Ways to be a Better PHP Developer at Hacking Ajax, and it was completely different. Personally, I agree with you more, because this article makes a little bit more sense for me

  1. 1 Bryan’s Blog: 5 (More) Ways to be a Better PHP Developer | Development Blog With Code Updates : Developercast.com Pingback on Feb 14th, 2008 at 12:45 pm
  2. 2 志凡’S BLOG » 成为更优秀的PHP开发人员的五点建议 Pingback on Feb 16th, 2008 at 11:24 pm
  3. 3 Olivier Pons » Archive du blog » Dix façons de devenir un meilleur développeur PHP Pingback on May 12th, 2008 at 12:37 pm

Leave a Reply