programming

Don't Wait, Delegate! Proper use of threading and queueing

There are hundreds of ways you can improve your app or website's performance, but few have the potential to improve your app or website's responsiveness as much as queueing or using background processes. There are so many complex operations that can be improved by looking at them in a new way. For example:

Not-so-Instant Oil Change

I like changing the oil in my car, but it often takes a bit of time (definitely not an 'instant!'), and involves the following:

  • Drive to auto parts store, pick up oil and oil wrench, and drive back (30 minutes).
  • Jack up front of car on stands (5 minutes).
  • Drain oil into oil pan, remove old filter, prep new filter (5 minutes).
  • Install new filter, refill oil reservoir (2 minutes).
  • Remove jack stands, clean up mess (5 minutes).
  • Drive to oil disposal center with old oil in pan, and drive back (20 minutes).

Total elapsed time: Over 1 hour! Maybe it's worth spending a few extra bucks on an 'instant' oil change to get back 45 minutes of my life.

Dreaming in Drupal

How do you know you've been thinking about work too much? When your wife relates a conversation she had with you in the morning, and you don't remember a word, but can definitely see how what you said relates to what you're working on:

Saith my wife: "Jeff, how do you set your alarm?"

My (groggy) reply: "Hit field, the arrow, then default."

Now, this could possibly have something to do with alarm clocks. There are often arrows on them, and you hit buttons... but I know better. I was referring to:

$this->addFieldMapping('field', 'source')->defaultValue(0);

...which I have probably typed about 100 times in the past week, and maybe 20 or so last night during a late-night debugging session with the Migration process of flockNote v2 to v3 (from a proprietary WAMP-based system to a new Drupal 7 LAMP-based system).

On Writing Documentation

I've been slowly reading through "Coders at Work," an excellent book in which Peter Siebel interviews many different programmers on their work and craft, and I hit a great little snippet of advice from Peter Norvig:

"The overall design of what's going to do what, that's really important to lay out first. It's got to be something that everybody understands and it's also got to be the right choice."

Basically, before you start doing some huge project, have a bit of a meta discussion about what you're trying to do. Document the process / steps, make sure it makes sense, and code to that process. You don't need to necessarily comment on every little tidbit of code you write—code should be somewhat self-explanatory if written well—but you should at least document what your functions do, and what kind of idea you're trying to implement.

Plus, if you document beforehand, you'll be able to conform code to documentation, and at the end you'll have a framework of your docs already complete!

Catholic Programmer's T-Shirt and Mousepad

Reposted from Open Source Catholic:

A few weeks back, after finishing a full day of swimming in PHP, HTML and CSS, I was pondering the great mystery of human existence, but probably had a little too much to drink. The result?

Catholic Programming - Design

You can buy the design on the following products (via Zazzle):

Would you like the design on anything else? I could do a mug, or socks, or anything else in Zazzle's catalog...

Alternatively, can you think of a way to code this better? ;-)