A Call for Memorization

By Deane Barker

Someone (I don’t know who), said “Half of intelligence is knowing the answer. The other half is knowing where to find the answer.”

In today’s world, we all know how to find the answer. But has that made us less inclined to know the answer from memory?

Google has just exacerbated this, really. There are so many things related to my job as a PHP developer that I just don’t bother to remember because the answer is one search away.

For instance: PHP date formatting codes. I have to look them up every single time. It’s the same with any number of function calls and input parameters (PHP is a bad example, since it’s all over map, but still…).

My point is that the Web tends to make us lazy in terms of remembering things that we’d normally study and memorize. Why do that when you can find the answer online in 30 seconds?

But is it really 30 seconds? If I’m cranking through some code and I suddenly have to break out of it to look something up, I’ve lost the all-important “flow,” and I have to stop and collect my thoughts, not to mention switching windows and such. Contrast that to being able to code right though without even looking up or wasting a single memory cycle on the answer.

And how much extra code have you written just because you didn’t know there was a function that did exactly what you’re trying to do? Or that there was some rock-simple code structure that you should know, but don’t (but would instantly remember when you found it after 30 minutes of looking…)?

All of this is aggravated by the fact that relatively few of us have formal training, and those that do are often trained on a lot of theory and not rote memorization. But there’s a lot to be said for memorization.

I was watching “Harry Potter” the other day, and Alastor Moody asked a class of students, “Who can recite the three unforgivable curses?” (Hermione could, that little brown-noser…)

Anyway, I suddenly envisioned myself sitting in a classroom and someone asking, “Who can tell me all the possible function calls for getting elements onto and off of the beginning or end of an array, complete with their input parameters and return values?”

Could I answer that? Maybe. Probably most of it. But how about this:

  • “What’s the format string for the PHP ‘date’ function to return ‘Sunday, November 27, 2005 at 9:26 PM’? You have three seconds.”

  • “Given a string of 1,000 comma-delimited words, turn it into a two-dimensional array sorted and grouped by the second letter of each word with dupes filtered out.”

  • “Fork the current process, run a shell command with the fork, then close it and provide the return value.” (Totally made this one up – not even sure if it’s possible.)

  • “What are all the possible PEAR modules to parse a text file into a data structure. What are the text formats and what structures do they return?”

  • “Name all the functions in PHP that either return or verify the data type of a given variable.”

  • “Design a data model for [insert scenario here] and write the DDL SQL for it. Longhand.”

Could you write perfect code for each of these without looking anything up? I hesitate to provide examples, because I know some of you could do these from memory, but you get the idea.

If your job depends on coding PHP every day, would you be better off if you concentrated just as much on memorization as you did on theory?

  • If you took 30 minutes every day to practice function calls and functional blocks of code from memory, would you be a better programmer?

  • Would you be more effective if you kept a set of flash cards in your pocket so that when you’re waiting in line at the post office, you could quiz yourself on the array keys for the $_SERVER global?

  • Should you reward yourself with something when you can write down the name of every single array function from memory? After that, give their input parameters. Then add their return values.

  • Given 1,000 of the one-line function descriptions in the official PHP documentation, would you be better at your job if you could match them with their function names? (That’d make a heckuva DHTML script…)

  • Would you find a better way to do things if you spent 30 minutes a day browsing through every function in one of the odd extensions that you’ve never used? (Memcache, anyone? Ming? Semaphores? CURL?)

Remember in college when you used to have to memorize a lot of stuff? Should you get back into that mode? Should we approach our profession with more of an academic bent than we do now? Do we disrespect our craft by not bothering to do this?

I think you’d be a better programmer for doing this. Like it or not, unless you’re a lofty “software engineer” who doesn’t write code, a lot of what we programmers do is rote memorization.

In order to build better software, you need to remove friction. And friction is not knowing exactly what tools you have in the shed, not knowing what all of them do, and having to drop everything to go look things up when you forget.

In saying all of this, let me repeat that I’m just as bad as everyone else (probably worse). But I’m willing to try and get better at it.

This is item #260 in a sequence of 356 items.

You can use your left/right arrow keys to navigate