Practical WordPress Development

Should We Share Old Code?

There have been times where I’ve considered pulling code down from the WordPress plugin repository or from GitHub because the way in which I write my code now differs from how I wrote my code when I was working on those projects.

GitHub Profile

And surely you know what I’m talking about: It’s not that the plugins don’t work and it’s not that they necessarily cause problems for anyone, but the open source nature of what they don’t necessarily represent what we’re capable of doing now or how we’re capable of doing it now.

Does that make sense?

Are You Look At My Old Code?

I mean, at one point in time we approach problem-solving in one way and we end up writing code that corresponds to what we know and how we think the problem should best be solved.

Fast forward years or even just months later we may have have taken a class, read a book, heard a lecture, or something similar that has completely changed the way in which we approach writing code. I think this is especially true in the world of object-oriented development, but that’s a topic for another post.

So, at some point in our careers, we have all of this code that’s out in the public – at least if you work in open source – and anyone and everyone can take a look at it. And you know what comes after that:

People are going to judge you capabilities and abilities based on the code you wrote.

And if it’s old code, then how does that make us look? Hello insecurity.

So in order to cope with being uncomfortable with this particular side of open source software, there’s a few things that I try to remember whenever someone contacts me who has stumbled across the work I’ve done.

1. The Problem is Solved

Above all else, the code was written and made publicly available because it solved some problem that someone was having even if it was just the author. And if that’s the case, the code is still useful even if it’s not the most well-organized, academically acceptable code.

And as much as I want to write the most efficient, clean, and well-organized code possible, whatever I’m doing now is likely not going to be what I’m going to be doing months from now. That’s something that I need to accept and move forward.

If someone asks me about it, then sure – we can talk. But I’ll hit on this a little bit more later in the post.

2. It’s For Posterity

I don’t know if the traditional resumé is dying or not, but I do think that sites like GitHub and bringing code samples into interviews and to talks with other people are becoming more common.

Having both old code and new code and everything in between can help build a case from where we were and where we are (and hopefully give an idea as to where we’re headed). This can prove to be useful for those who may be hiring us for jobs as it helps them to know if the work we’re doing jives with what they need in their business.

If anything else, it can serve not only as a reminder of where we once were (because, face it, you haven’t always been the high quality programmer you are now :), but it also helps to serve as a point of reference for how to do something – at least to some degree – for a problem we may encounter in the future.

3. You Should Ask For More

This actually placed to burden of responsibility on the third-party who is looking at your code. That is, if they’re passively reading things you’ve contributed and then have questions about why you’ve done something the way you have, why not just ask you about it?

We have plenty of ways to make contact information – email, Twitter, even GitHub issues or comments – so to take advantage of those if you have questions, and hopefully others will, as well.

Is There More?

This is somewhat of a rhetorical question. Yes, there’s more. There’s always more. But that doesn’t mean that I’m not curious about what you have to offer as it relates to your own experience with doing this.

So what are your thoughts on all of this? Eventually, sure, code becomes dated and incompatible but that doesn’t mean that it can’t serve some type of purpose. So I’m curious as to what you add to this post.

Comments – have at ’em!



  1. Timothy Brand

    I’ve never actually used Github because I don’t feel I write any code that would even be useful to people. I do need to learn to use it and get over that, but that’s off topic.

    While I can’t relate to old code, I CAN relate to old designs. I look at graphics I developed back in 2007 and 2008 and I do not want any of my clients to ever see that. At least that’s what I thought.

    While I dislike the graphics I did back then I had to realize the only reason I don’t like them now is because they’re not trending with current designs. It would be like Da Vinci not letting anyone see the Mona Lisa because he felt it wasn’t trending anymore.

    • Tom

      I’ve never actually used Github because I don’t feel I write any code that would even be useful to people. I do need to learn to use it and get over that, but that’s off topic.

      Bingo. It will help someone because you’re further along than someone else.

      And who knows – others may chime in with a code review that helps you learn to write better code.

      While I can’t relate to old code, I CAN relate to old designs. I look at graphics I developed back in 2007 and 2008 and I do not want any of my clients to ever see that. At least that’s what I thought.

      This is one of those areas in which I’m not really an expert or anything. All I know is that I can look at certain things on the web and have an idea as to when it existed (unless someone is trying to make it look dated) and then go from there.a

      • Timothy Brand

        I took the intro course to using Git. I’m still trying to wrap my head around the branches and things like that. However, I’m going to develop my first free theme this year and I’d like to get it on Github. So I’m going to HAVE to learn to use it :)

  2. Rick

    Your codes good Tom, is it as OOPie as your newer stuff? Prolly not.

    But OoPie is more difficult to trespass through for many than not, especially in the WP world where the outward facing code base is rather procedural.

    Lots of goop. I just spent some time wrestling getting posts/comments to not have the normal form mechanism. A friend wanted it as modal. While responding to a blog post is easy enough… Just embed the comment form call to WP insisde the Modal Div and Pop it with an onClick call or JQ attach events… Comments were a tad more, “Oochie coo”.

    A comment form hidden modal for each comment? Oh icky ick!

    Never thought too much about that process in my last what, 9 weeks with WP? Something like that give or take two. Ah, “Redirect” and in the redirect in WP sets up the form. I guess it causes Google Bots all sorts of consternation too as thats the only info I could find.

    So, time to examine WP source code. Did that. Without altering core or re-inventing the comment code to a “slug in” which may end up in a future build incompatible. Now what?

    I know! I will just attach a parameter to the URL Query string, look for it AFTER the redirect and presto! That should work. When I find it, Pop the Modal.

    Uh uh. WP filters off extraneous params as it comes back from the replytocom redirect.

    But its still there obviously. So, look for that. Presto.

    Then call a JS function that sets a flag and check for the flag when DocReady completes and if its true, pop the modal. Presto Modal comments.

    I didnt check if there is a hook yet, do it proper. He also wants the comment being responded to to sit in the modal with a cut/paste ability which should be a breeze.

    So… TELL me. How would you have approached this task. Again, I am rather new to the codebase. Just curious how you’d have attacked this.

    • Tom

      So… TELL me. How would you have approached this task. Again, I am rather new to the codebase. Just curious how you’d have attacked this.

      I’d consider appending a hidden field to the comment form and reading it from the $_POST data when the page refreshed.

      And, as a last ditch effort which feels more like a hack, I would have written a value to the database, then on the next page load checked to see if the value existed. If so, do my work and delete the value.

      Again, the last is the least of my worries. The second option is probably my favorite because we can use a filter like those listed here to update the comment field.

      • Rick

        Using $_POST is what I ended up doing. I did see some code that uses a Form and Posts to wp-comments-post.php looked like the old way things were done?

        Also did some work on a OOP template engine last night, Dunno how its going to turn out. But from cursory funsies it could make theming a WHOLE lot simpler. Bit more memory munchie which is to be expected. I do need explore some WP source, I presume WP does cache template parts?

        I did all the enque’s, post formats, menu’s etc. which after registration etc. is done release the objects back to the heap ( be it admin or front facing). I’m not real in the “know” as to how PHP manages garbage collection but I assume its along similar mechanisms to other managed code. Presumably forcing destruction if the heap gets scant as one of the mechanisms?

        I probably should not worry about such things but thats the old school coder in me. Since really the first high level language I dealt with was C where its always a good idea to release allocated ram soonest possible to A. Free Ram and B. Not forget to free ram and C. since C++ is very “pointer centric” shall we say not having pointer math result in memory leakage.

  3. Dwain

    Old code can make you look bad if you’re not sharing all the tme, but if you are then the resume should keep getting better.

    • Rick

      Every recruiter I’ve ever dealt with doesnt place any thoughts on old codebase at all and I worked in the most miserable industry of it, games.

      Now in as far as WP goes, its a good resume if your doing WP work. The fact so much is procedural is more an issue if one were looking at code. If I were a recruiter and someone showed me WP code, most recruiters or head hunters not know WP is quite procedural in many areas, that’d send up flares.

      They seek object oriented code. If one is stepping out of wordpress then I’d say have a directory with the WP stuff in it with a nice big fat read me first with explanation “WP is a hybrid of both procedural & Object Oriented code blah blah”

      Whether “PHP” is the place to be, well thats a whole different bucket of bolts.

      But your MS MVP anyways? I presume your keeping that skill set in good standing in as far as MVC / Razor etc? No matter what additions they make in .NET libs, that can generally be “caught up upon” should the need arise. But more of the core things I’d keep “watch on”, Mono for example. Keep a sorta file with a “poop” sheet so anything significant gets noted as a “fallback”. So should you need hop back to .NET you can sorta hit the ground running.

Leave a Reply

© 2020 Tom McFarlin

Theme by Anders NorenUp ↑