The Pitfalls of PHP – PHP and Messy Code

I really like PHP. I like how it is not overly complex, and how it provides freedom in how to put together websites.

However, what has been growing on me over the last few years is what I don’t like about this freedom. Giving other programmers the freedom to write very sloppy code. An example of this is object oriented programming. If this is utilized correctly in PHP, it is meant to make maintenance and updates a lot easier. It also is meant to save time by giving you access to code that has already been written for the system. However, if you get a PHP programmer writing OOP, but they don’t really understand how to use it….you sometimes end up with what I like to call “nightmare code”. Simple tasks or bugs end up taking hours and sometimes days to figure out, because you can’t figure out what the original programmer was trying to do.

That is what irritates me. You end up trying to heal a dead horse, and sometimes you just end up making it worst. When you think you fixed it, you end up missing some other part of the code that is effected by what you just did, and you just made matters worst. In a production environment, you feel so much pressure that you are not able to spend the time in correcting the problem…even though you know that this would end up saving a lot of time later on.

The lack of indentation and the lack of general best practices in programming seem to be none existent with some PHP programmers. Some of them don’t understand why it is probably not a good idea to name a variable $nduh (I absolutely hate abbreviations with variables in PHP…it is like a secret code that only the original programmer can figure out what it actually means).

I was going to write up an example of this ugly PHP code, but I’m having a hard time justifying spending the time to do it. If you have any handy examples of just horrible PHP code, please send them to me and I will post them on the site.

Advertisements