A while ago I read a blog post that Elizabeth N wrote, on the value of writing self-serving code. Ever since I've been moderately aware of when I've written self-serving code, usually either at hackdays, or just little projects where I'm either experimenting with something or just bashing out a new idea.
In fact, I even wrote about one of my recent "self-serving" projects I bashed out in an evening, TweetSavr. It has no tests, was written moderately quickly and not refactored immensely (here's hoping the git history backs me up on that! I certainly didn't knowingly majorly refactor it at any point at least.) But it "scratched an itch" and solved the problem I had, and it works for the limited use case I need it to, so it's a success as far as I'm concerned.
More recently a friend remarked to me in a private conversation that everyone needs to procrastinate occasionally, to save them going "stir crazy". Whilst I agree with what she said, everyone needs to switch gears and do something that perhaps you shouldn't, or that won't directly contribute to completing your current task, I couldn't help but draw a link between procrastinating and writing self-serving code.
Now I'm a programmer, it's what I did for a hobby through school, it's what I leapt into a career doing when I was offered the chance and even when I've had a particularly exhausting week, it's something I'll eventually turn back to. But I realised that often when I procrastinate, I do so by writing self-serving code. My creative output or process if you will is to create things digitally on the computer, be that a web app, hacky script to let me do something I'm not supposed to be able to with someone else's application, just dicking around or exploring whatever tidbit of interesting info/behaviour in a language or library someone's just shared on IRC.
Aside: I've often joked (semi-seriously) that if/when I have enough cash in the bank to not have to actually have a "day job", I'll just spend all day building the random ideas that get tossed out on IRC instead. Quite often the smaller things I code up anyway already of an evening and they end up in my gists.
Now it's unhealthy and counter-productive to want to program 24/7, at least in the long term. (Doing the odd 24 hour hackday event here and there can mean winning fun prizes to play with however.) And sometimes all that you need to do to solve a problem you've been butting your head against for the last couple of hours is to get off the damn computer. (I usually find taking a shower makes my subconscious reveal the answer it's been quietly computing and hey presto, I know how to solve the problem properly!) At other times it just requires changing gears and flexing a different part of your brain muscle. Like say, writing self-serving code. And procrastinating by doing so.
I'm not entirely sure what the point of this thought process is, or if there can really be a point to it, but it really intrigued me drawing a link between procrastinating and writing self-serving code. I can imagine other creatively minded people might do much the same thing, an artist just sketching for the sake of sketching, or a writer taking a couple of hours off from her next novel to write a short story for her blog. (That last one is actually something a friend's done, go read her short stories, they're quite good. Start from the bottom though.)
And of course sometimes you just need to vegetate and read facebook (or twitter), but constructive procrastination does serve a real purpose I think, and can be quite useful as well.