Here you can find the notes I took while reading “The Programmers Brain” by Felienne Hermans. The notes aren’t exhaustive, but they show what I got out of the book.

Reading code is a larger part of a programmer’s working life than you might realize. Research indicates that almost 60% of programmers’ time is spent understanding rather than writing code. Thus, improving how quickly you can read code, without losing accuracy, can help you improve your programming skills substantially.

Comprehending Code

  • Determine Importance: Which parts of the code are significant? This helps you find an entry point.
  • Infer: Fill in facts about what the code does.
  • Visualize: Draw diagrams of how the code works to deepen understanding.
  • Ask yourself questions about the code.
  • Use refactorings such as inlining functions or reordering them.
  • Replace unfamiliar code constructs.
  • The amount of information you can process at a time is limited [1]. Hence, it is vital when you trace through code step by step to use a memory aid.

Writing better code

  • Variable name quality is decided early in the project and then sticks.
  • Agree on common name molds early in the project.
  • "Name molds are patterns in which elements in a variable name are typically combined." E.g. max_benefit_per_month vs max_num_of_benefit
  • To choose better names:
    • Select the concepts to include in the name.
    • Choose the words to represent each concept.
    • Construct a name using these words.
  • Code smells force you to read code line by line because it isn’t easy to comprehend
  • Use design patterns to write code that can be comprehended in chunks [2]
  • Leave Beacons, beacons are triggers for you while comprehending code. They help you reject or confirm an assumption. There are simple ones, like structural elements or meaningful variable names, but also complex ones which provide semantic meaning.

Read More code!

Although Sweller’s experiments focused on math teaching, similar experiments have been done for programming. Those studies showed similar results: kids learn more from reading programs, plus an accompanying explanation, than from programming.[4] As Dutch psychologist Paul Kirschner says, “You don’t become an expert by doing expert things”.

Links to get started with reading more code: