9 Avoiding bad code and cognitive load: Two frameworks

 

This chapter covers

  • Explaining the connection between code smells and cognitive processes, especially cognitive load
  • Surveying the connection between bad names and cognitive load

As a professional programmer, I am sure you have seen code that was easy to read, as well as code you had to spend a lot of effort to understand. The reason code can be hard to understand is something we covered in earlier chapters when discussing STM, LTM, and working memory: you are experiencing too much cognitive load. Cognitive load happens when your working memory becomes too full and your brain cannot properly process anymore. In earlier chapters, we focused on how to read code. We have seen that sometimes you need to gain more knowledge of syntax, concepts, or domain knowledge to read code with greater ease.

9.1 Why code with code smells creates a lot of cognitive load

9.1.1 A brief intro to code smells

9.1.2 How code smells harm cognition

9.2 The influence of bad names on cognitive load

9.2.1 Linguistic antipatterns

9.2.2 Measuring cognitive load

9.2.3 Linguistic antipatterns and cognitive load

9.2.4 Why linguistic antipatterns cause confusion

Summary