I run a number of web sites with WordPress, and have recently upgraded many of them to WordPress 3.0.1. It seems that every time I have to upgrade WordPress that some of the many and varied plugins are simply broken.
Why is this? I mean, in this day and age of well-defined APIs, OOP, proper object factorization, unit testing, and the like, you’d think this would rarely happen, right?
But, alas, the real problem is that most WordPress plugins are simply horribly written. Period. Way too much dependence on global variables, no use of PHP’s OOP capabilities (even though WordPress definitely supports OOP), and just poor code organization all around.
So, whenever WordPress changes something, lots of plugins simply fail to work properly. It’s so prevalent it drives me mad.
Proper software design principles applies whether you are programming in C++, Ruby, Perl, Java, or PHP. We have those design principles in place for a reason. Popular applications are never static, and should never be expected to be either. That’s why we do certain things in a certain way, folks!
Of all the languages I know, I consider PHP to be the absolute worst, basically the Basic of the 21st century. Because just like Basic, PHP allows to get away with many ills. It allows you to write very sloppy code very quickly, and actually get it to work “good enough” to throw into production!!!!
But when you are talking frameworks and plugins, there is no room for being sloppy. When you are talking millions of users that must rely on your plugins, there are simply no place for taking shortcuts. You do the job right, or not at all. You adhere to the well-established, sound design principles that we have worked out over the past 30 years or so, or you go back to “school” to get a clue.
But I really fault PHP for allowing such evils in the first place. Ruby and Python strongly encourages you to do the right thing when you write code. Ruby on Rails is sweet in this regard.
In my experience (and I have 30 years of it!), it takes just as long to write good code as it does to write bad code. With bad code, you spend much more time debugging it, and “fixing” the bugs probably entails writing more sloppy code to work around the existing sloppiness. So time wise, you’re a penny wise, pound foolish.
And then comes maintainability. With poorly written code, forget it. The time it takes to maintain it blossoms exponentially over time as the underpinnings shift and evolve over time. With Open Source development, what usually happens over time is one of the following:
- The code is abandoned and everyone stops using it.
- The code is re-written from the ground up (and using proper design principles finally!!!!)
- The code has become critical to many applications, but no one truly wants to maintain it because it’s so horrible, so it “limps along” with the barest minimum effort applied just to keep it — somewhat — running.
All of which could’ve been avoided if the code was written properly up front. That would free developers to work on more cool stuff, giving us even more functionality, and also allow the underlying frameworks to also grow and expand without worry of breaking all the plugins and themes out there.
So get a clue you bad PHP code slingers out there! It’s not hard at all writing good code, and is actually quite enjoyable. Spend less time playing video games and more time to educate yourself. It’ll look good on your resume and improve your bottom line. And make those who use your code happier. Why? Because your code won’t call attention to itself by not working, and your name is far less likely to become an expletive.
It’s up to you. Only You can write Good Code. If not you, then who else?
