I am a hands on, visual learner. I need to see something and to play with it to understand how it works. When reading a book, I take notes, highlight, underline, and circle the text to help reinforce what I’m reading.
Reading Code
When reading code, I tend to draw pictures of what the code is doing. These can be simple workflow diagrams. They can be interaction diagrams. They may end up just being a bulleted list of what goes on in the code.
The ability to read and parse code is a skill that needs to be developed. It doesn’t really come naturally to most. We tend to do fine reading the code we write, because we are used to it. We know how we think. Reading the code of others requires us to peek into their minds.
Some don’t write any tests. Some smother the code in tests. Comments are useful, but some write comments to the point where they are noise. Yes, I know the “getThing” method will return a “thing”. I didn’t need 6 lines of comments on a one line method. Other times, the logic is so complex, or convoluted, that you wish any comments existed.
Deciphering Code
There are many things to hold in your head when reading code. You have to actually parse the code. You have to know the context of where you are. Remember the collaborators and callers. Taking notes and drawing pictures can help offload some of that work.
All of these pictures are throw away. You can’t keep them. Reading them later won’t help you. They won’t make any sense. Plus, the code may have changed between the time you drew the picture and now.
The ability to load the code up in your head and draw these pictures becomes easier the more you do it.