5 Reaching a deeper understanding of code

 

This chapter covers

  • Examining the different roles that variables can play in programs
  • Comparing surface knowledge of code and understanding of the intent of the creator
  • Comparing reading and learning natural language to reading and learning code
  • Exploring different strategies to gain a deeper understanding of code

Earlier in this book we discussed using flashcards and repeated practice as techniques to learn syntax, and we covered strategies to quickly familiarize yourself with new code, such as highlighting variables and their relationships. While knowing syntax and understanding the relationships between variables is an important step to understanding code, there are deeper issues that play a role when thinking about code.

When you read an unfamiliar piece of code, it can be hard to see what the code is doing. To use a cognitive term introduced earlier in this book, you might say that when reading unfamiliar code, your cognitive load is high. We have seen that cognitive load can be lowered substantially by learning syntax and new programming concepts and by rewriting code.

Once you have a good understanding of what the code is doing, the next step is to think about the code at hand in more depth. How was it created? Where might you add a new feature? What are some possible design alternatives?

5.1 Roles of variables framework

5.1.1 Different variables do different things

5.1.2 Eleven roles to cover almost all variables

5.2 Roles and paradigms

5.2.1 Benefits of roles

5.2.2 Hungarian notation

5.3 Gaining a deeper knowledge of programs

5.3.1 Text knowledge vs. plan knowledge

5.3.2 Different stages of program understanding

5.4 Reading text is similar to reading code

5.4.1 What happens in the brain when we read code?

5.4.2 If you can learn French, you can learn Python

5.5 Text comprehension strategies applied to code

5.5.1 Activating prior knowledge