Memorability in Programming

I’ve mentioned previously that a key skill in software development is the ability to keep a program (or large parts of it) in your head. It lets you see how things work together, build on the code, and troubleshoot problems in a systematic way.

The human memory work works well with associations. You remember the alphabet in order – try recalling it backwards and you’ll see what I mean. It’s not just the letters, it is how they are associated with each other that you recall. Also, the more associations you can form, the less unique things you need to remember. This is why mnemonics (e.g. Roy G Biv for colors in the rainbow) work so well. You are basically creating pathways to a whole stack information through a key.

In terms of programming,  memorability is great. It allows you to make logical associations about the code. That is, until the associations start breaking down due to poor exceptions. Things like finding that “usually a reference to a user is singular, except in this class where it is plural”. That’s why consistency is king in programming. The more consistent you are, the easier it is to follow your program.

Commenting, is handy, but just as useful are techniques that bring about consistency such as your naming convention. When done correctly, It leads to moments like, “Ah, this variable is called xyz so it must be derived from class abc. Nice!” Conversely, one of the most frustrating situations is when you make an assumption about the code that should hold up based on the convention, only to find it doesn’t apply in this particular situation (lack of consistency).

So seeing as programmers mainly read code to understand it (and not write it), I think the ability write code that is easy to remember (and therefore easy to follow and understand) is just as important as any other software development skill.