Episode 035: Level Up As a Developer 3, WordPress and PHP

Aired: 06/07/2016
Special Guests Tom McFarlin

This is our third episode on “Leveling Up” as a WordPress Developer and this time we are focusing on 1 specific language, PHP. PHP is the language that WordPress is built on, and while many people even learn PHP before turning to WordPress, WordPress itself has been a great stepping stone for developers to learn PHP.

We did not cover the very basics of where to start, since we covered that in our previous episode. If you want to just start out, easing into PHP, a good way to do that is to add some functionality to a theme or create a new plugin that does something very simple.

OOP vs. Procedural PHP

You may here many developers talk about OOP or Object Oriented Programming when it comes to “good code” or “advanced code”. What is OOP? There are many ways to define or create a metaphor for OOP, but I think Carl said it best. OOP is like Lego, each class is a block, properties of that block define out how large it is, what color it is, and other things that make it unique to other blocks. Procedural programming is something you may be more familiar with when just starting with PHP, where typically functions are global, and they call on other functions in a procedure to get the result you want.

Is WordPress OOP?

We had a little bit of a debate about this one, since WordPress does have classes, and classes are the “objects” in OOP. While Tom said that WordPress is OOP, Carl disagreed saying that it didn’t take it to the next level of OOP, and classes where there just to block functionality together. What is your take? Is WordPress OOP?

Roy loves OOP for other reasons, including modularity. In most OOP builds or apps, each piece of functionality is completely modular. During Russell Aaron’s an open discussion at WCSD we talked about a modular WordPress, where lets say “Users” or “Comments” could be completely removed from the core if you did not need them. Modular coding also means that those pieces can be replaced, or functionality added without it affecting other parts of the core code.

Procedural is easier

Procedural coding is a little easier to grasp, and many people stick to it. They know how to do basic PHP function calls like the_title(); and that is all they need.

Not far enough

Tom brought up a good point that many developers who start learning about OOP quickly because they learn how to create a class but then don’t learn what else they can do with it. Bundling functionality is great, but once you get into even further advanced things like abstract classes and polymorphism you can quickly see how powerful PHP can be. So most developers stop with OOP too early and don’t take it far enough to really see how useful it is.

Quote of the Episode

“I can’t stand it when people gives those kind of examples… I’m never going to make digital toast” – Tom McFarlin

Further Reading

Our very own Josh Pollock interviewed Carl over on TorqueMag about Leveling up with PHP. Make sure to read through that after watching the podcast above!

oop php

Leave a Reply

Your email address will not be published. Required fields are marked *

  
Please enter an e-mail address

This site uses Akismet to reduce spam. Learn how your comment data is processed.