Chapter 1. How to read complex code
Chapter 4 from The Programmer's Brain by Felienne Hermans
This chapter covers:
- Analyzing what happens when your working memory is overloaded by very complex code
- Comparing and contrasting two different types of working memory overload when programming
- Refactoring code for readability to compensate for an overloaded working memory
- Creating a state table and a dependency graph to support your working memory when reading complex code
Chapter 1 introduced the different ways in which code can be confusing. We’ve seen that confusion can be caused by a lack of information, which must be acquired and stored in your short-term memory, or by a lack of knowledge, which requires storing information in your long-term memory. This chapter covers the third source of confusion: a lack of processing power in the brain.
Sometimes the code you are reading is just too complex for you to fully understand. Because reading code is not an activity that most programmers practice often, you might find yourself lacking strategies to deal with reading code that you do not understand. Common techniques include “read it again” and “give up,” neither of which is that helpful.