The Day the Bacon Attacked

For those who don’t know, I work remotely for a Japan-based company called Delfi-Net.  Every day at 9am Japan time, we have Standup — a call to discuss what’s going on and for each team member to bring others up to speed with our various projects.  This is all normal and happy for most developer types.

I’ll also let you know that my family and I live on a small farm here in north Arkansas with a myriad of livestock and critters of all sorts.

I tell you those two things so I can tell you this….

During today’s Standup, my awesome wife thought it would be fun to bring a miniature potbelly piglet into my office and put it right next to my head.  Let’s just say this went over about as well as could be hoped.  Thankfully this entire exchange was recorded, and I get to present it for you here.

 

Standup with Pig Surprise - 14 July 2015     

All That Glitters Is Not OOP

I’ll start by telling you that I’m an old developer by most visible standards.  When I started with PHP 3  after coming from Perl, register_globals was considered a good thing and articles online would tout how easy it was to deal with form vars because of it.  Fast forward a bunch of years and the concept doesn’t even exist anymore.  It’s much better for security of course; I’m just using it to point out how things change and progress.

For a time, I was finding myself without regular income, so I started looking around at the current programming world and was feeling very discouraged.  I’ve churned out tens if not hundreds of thousands of lines of code over the years and feel very confident in my abilities to solve peoples’ problems, but it seemed with so many new things (and more new things every week), that I wouldn’t ever be able to keep up.  It was depressing.

In the “modern PHP” world, everything is Frameworked, Composerified, Autoloaded, Injected, Inherited, etc.  That’s a good thing overall, but it’s not everything that is PHP.  The problem is that so much code still out there running the web sites of the world don’t use all, if any, of these things.  And not every task that needs to be done needs to use them either.

Then I started reading more and saw that some of the really big names in PHP aren’t so super gung-ho on big frameworks for everything either.  I like hearing Rasmus Lerdorf say that his favorite framework isn’t necessarily a framework at all, but whatever is the best tool to get the job done at the time.  Cal Evans said something much along the same lines in an interview with 7php.com.

Most of what I’ve been doing for the past few years revolved around PHP apps that employed some OOP principals and design patterns, but not what you see today.  I had to figure out what to do to get what I wanted with them.  And I think that goes for a huge portion of the internet still.  There are thousands of coding projects out there that need work done but there’s no budget for a ground up rewrite in Laravel or Symfony or Silex, etc.  Instead, they need some modifications or additions to solve a particular problem.

The (potentially sad) reality is that there are millions of successful web sites on servers still using PHP older than 5.2 running hundreds of millions of lines of procedural code that’s not ready to be replaced quite yet.  Somebody has to be there to support and help fix them.  That somebody may be an up and coming junior programmer, but it may be an old fogey like me too, so don’t be quick to judge without knowing what you’re dealing with.

Read the Manual!

I’ve been coding PHP for several years now.  Granted, I’ve learned a lot by taking apart other people’s scripts and applications over the years, but there is still no substitute for reading the manual!

It may seem boring or a waste of time, but if you want to be good, take some time at least once a week and read through the PHP Function Reference.  The reason this is so helpful is that the more functions you can expose your mind to and the more often you do it, the more likely you’ll know what function to use to accomplish your task at hand.  It’s been said many times that with any programming language, there are at least a half dozen ways to accomplish something — PHP is no different.  So chances are there’s a built-in function to do what you need.

If you don’t really know where to start, I’d suggest starting with Strings or Variables then move on to Arrays.  One thing you’ll start to notice as you read the examples is that most functions will reference other similar or complementary functions.  And you can click back and forth between functions as you build a grasp of how to do different things in PHP.

Also, at the bottom of nearly every function will be many user-contributed comments with code snippets, etc.  These are a great way to learn how to use the function in question or even ways to mimic that function but with more power or flexibility.

Don’t try to force yourself to learn the exact syntax for every function, the main goal is to familiarize yourself with what the various functions do so that when you need one, you’ll at least know where to look.

I hope that somebody gets some value from this first post.  And I hope that future posts will be even more useful as I find other ways to let some of the code-induced steam out of my noggin.  Thanks!