Programmer’s memory

By pairing with a wide variety of other programmers, I've noticed that the programmer's memory has an important impact on the productivity. In order to be agile searching for code blocks within a file, we must remember the structure of the code, be familiar with the code geography. We should have a mental map of the file that we can handle in our heads, so as to remember whether certain block is located near the top, near the middle or at the bottom of the file. When the file is too big or the developer doesn't make an effort to build the mental map, he starts using the IDE's search feature to navigate everywhere, even when the code block is present in the current screen. Searching for code blocks with the IDE all the time, stops the flow and thus reduces productivity. The focus goes away. Well, this is what I've seen and I've experimented whilst pairing.

Different people have different memory capacity, the trick is to be aware of your capacity and manage it accordingly. If you can't handle files longer than 300 lines of code, then keep your files below that size. When you find yourself using Ctrl+F to search for a function name often, consider splitting the file into several ones.  The same applies for packages, modules, namespaces... try to group artifacts so that you can handle a mental model that contains all you need to work on the task or feature at hand.

Coding requires a lot of concentration and all the attention that we can put on ourselves to improve our own process day after day. Every coding session is an opportunity to learn and improve. Specially when you pair and get immediate feedback from your pair.

I believe this has a relationship with developer's preferred font size. The bigger the monitors are, the smaller I see people's fonts. I need a magnifier to be able to read to code sometimes, I always have to ask them to enlarge the font. Smaller fonts means more lines in every screen but anyway, most people work with horrible mountains of legacy code and it doesn't fit in even 5 screens!

Use your memory and save your eyes!

Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
  • Pawel Duda

    Hi Carlos! I like the “embracing your limits idea”. You mentioned the limit of keeping the mental model of big files which might lead to splitting big files (which generally speaking tends to result in better code). My example is, I personally am worse than an average programmer in handling complexity and this limitation has made me write cleaner code. And finally, I’ve got similar impressions about the font size 🙂 Lots of people I know will set the font size to something tiny because they want to see more on the screen. And yes, while they get to see more lines vertically, usually the right half of the screen is almost entirely empty (code lines aren’t usually very long). So there’s huge waste of space there. Further, because the font is small I see them quitting a straight sitting position and moving their head closer to the monitor. Some of them, if you observe their face, actually struggle to read small fonts so you will see their eyes squinting and “wrinkling” (not sure what the right word is :)).

  • http://www.carlosble.com/ Carlos Ble

    Hi Pawel!
    Exactly, this is about being aware and embrace oneself limits 🙂

    I think the reason why many of us come to XP practices is because we get to a point where we recognise we are not the brilliant brain we thought we were at the beginning of the career.

    Craftsman have to be humble, isn’t it?

    Thank you!

  • Danijel Arsenovski

    We know that human memory works best with information that is organized and structured. Above all, human memory favors meaning. So, if
    your code is well designed, clean and refactored, uses well known patterns, models and metaphors, you will be in much better position to memorize and find your way around the codebase.