Join the Cult: Converting to Object-Oriented Programming

Last week, my wife decided to start learning PHP.  And no, she’s not just trying to humor me–pssh, like she’d do that.  She’s burning to code some roleplay generators.  It’s a bit of a blast, sitting and coding side-by-side.  (And not just because I get to work on Escher without feeling guilty!) She’s doing a great job, picking it up like lint, and it’s fun to see her sense of accomplishment.  I miss that sort of instant gratification that came in old days, before PHP became a paying gig and I started counting lines of code by the tens of thousands.  Say what you will about rapid development frameworks…  Nothing beats the efficiency of a single-file script running linear or functional code and inline HTML.

For a small project, at least.  Since she’s been doing so incredibly well, I thought I’d try and show her a thing or two about PHP classes so she can get her code more compartmentalized and portable.  After all, in the past week, this endeavor has grown from a simple desire for a few one-off scripts to the possibility to create our own RPG system and an accompanying website.  So we might as well start thinking ahead, and no better way than OOP, right?

Oh, wait…

OOPs.  (Yeah, I went there.)

In my arrogance, I’d forgotten something significant about object-oriented programming.  Nevermind that OOP is a godsend, that for large projects it makes things exponentially more manageable, or that we proabably all use a lot of OOP whether we know it or not, thanks to all the libraries and database wrappers and even a lot of built-in PHP5 functionality.  There’s something off-putting about OOP when you aren’t already coding it.  It seems unnecessarily complicated, and there are really no great & simple ways to describe its advantages.

Heck…  I hated OOP.  With a passion. I avoided it for years, and managed to build a pretty respectable website without it.  OOP was just a cult, and they were never gonna suck me in.  Well, now look at me.  I’ve joined the cult, I’m sporting the weird haircut, and I’m sippin’ the koolaid daily.

So, how can I explain OOP to my wife in a way that makes sense?  (Not makes-sense makes-sense, but makes-sense why-should-she-bother?)  The real-world analogies never worked for me.  (”You’ve got a building object, and a door object, and maybe we want to extend a door object to have a lock…  yadda yadda…”)  Even still, I find that those analogies actually screw up my perspective on a project, I think because physical hierarchy and structure is just plain different from programmatic hierarchy and structure.

I think, perhaps, the best analogy for OOP programming might actually be non-OOP programming.  Functional programming, at least.  The automation and portability provided by writing our own functions is not difficult to see first-hand.  OOP actually behaves in a very similar manner, and takes our portability to the next level.

Read the rest of this entry »

No Comments


New Theme: Fusion

I’ve installed a new theme for the blog: Fusion by Digital Nature.

The layout and positioning are not quite to my tastes, but the subdued, neutral matte color scheme is right up my alley at the moment.  I’ve tweaked a few elements–sidebar width, search bar, header height, etc.–to be a bit more compact.

I had wanted to design my own theme, but I decided to swallow my pride and just pick one, because I don’t want this blog to feel like work, and I’ll never write here if I feel like it’s unfinished.  So this will do for now.  Perhaps I’ll build my own theme when & if I convert this blog from Wordpress over to Escher.

No Comments


The world feels alive today

Today, Barack Obama took the oath of office.  The bigness of this day is probably unprecedented in my twenty-some years.  Of course, it doesn’t compare to an experience like getting married, those personal experiences that make you feel alive.  But as the world goes…  Well, today feels as big and significant and important to the rest of the world as my wedding day felt to me.  The world feels alive today.

Before this election, I think I’ve only ever felt the world, in that personified form, when it had been in pain.  I remember being in Kindergarten and shocked at the news of the Challenger explosion.  And I remember being in my dorm at college and turning on the news to watch the World Trade Center tumble in slow motion.  Aside from those experiences, “the world” and I have always remained little more than detached acquaintances.  Certainly I’ve had my opinions about how the world should be, what’s wrong, what should improve; but I never really had any emotional investment in it.

So it’s great to experience a day that’s both historical and positive.  It’s not quite so surreal as a moon landing, and I’m ill-equipped to guess if it’s bigger than JFK being elected, but my guess is yes, it probably is.

It’s made bigger by the racial significance–I still have to be reminded about that.  Same as after election day…  I was so excited just to know that we had elected a brilliant & impressively charismatic man to turn our country around, that I was only reminded nearly after-the-fact that he will also be our first black President.  I still honestly consider that to be an afterthought–we need good leadership right now, no matter who it is–but the racial significance is huge, just the same.  (I wonder if, when the first woman gets elected President, it will be as celebratory a time.  Perhaps only if she, too, will be replacing a terrible lame-duck President?)

So this will probably be the election/inauguration I will always remember…  Our JFK.  I wonder what our “moon landing” moment will be?  I don’t think a Mars landing will really have the same appeal, and although I hope for some clean-energy milestones in my lifetime, I’m not sure if there will be any awe-inspiring moments to watch.  I’m gonna go out on a limb and say our big moment of technological advancement will have something to do with robotics and A.I.  Could be creepy!

What an awesome day…  Truly.  Not simply “awesome” in the overused, Teenage Mutant Ninja Turtles sort of way…  (Although on that note, let me be the first to offer our new President: “Cowabunga!”)  Awesome in the true sense of the word: inspiring awe, admiration, or wonder.

Or D: All of the above.

No Comments