The Programmer's Brain

Book description

Your brain responds in a predictable way when it encounters new or difficult tasks. This unique book teaches you concrete techniques rooted in cognitive science that will improve the way you learn and think about code.

In The Programmer’s Brain: What every programmer needs to know about cognition you will learn:

  • Fast and effective ways to master new programming languages
  • Speed reading skills to quickly comprehend new code
  • Techniques to unravel the meaning of complex code
  • Ways to learn new syntax and keep it memorized
  • Writing code that is easy for others to read
  • Picking the right names for your variables
  • Making your codebase more understandable to newcomers
  • Onboarding new developers to your team

Learn how to optimize your brain’s natural cognitive processes to read code more easily, write code faster, and pick up new languages in much less time. This book will help you through the confusion you feel when faced with strange and complex code, and explain a codebase in ways that can make a new team member productive in days!

About the Technology
Take advantage of your brain’s natural processes to be a better programmer. Techniques based in cognitive science make it possible to learn new languages faster, improve productivity, reduce the need for code rewrites, and more. This unique book will help you achieve these gains.

About the Book
The Programmer’s Brain unlocks the way we think about code. It offers scientifically sound techniques that can radically improve the way you master new technology, comprehend code, and memorize syntax. You’ll learn how to benefit from productive struggle and turn confusion into a learning tool. Along the way, you’ll discover how to create study resources as you become an expert at teaching yourself and bringing new colleagues up to speed.

What's Inside
  • Understand how your brain sees code
  • Speed reading skills to learn code quickly
  • Techniques to unravel complex code
  • Tips for making codebases understandable


About the Reader
For programmers who have experience working in more than one language.

About the Author
Dr. Felienne Hermans is an associate professor at Leiden University in the Netherlands. She has spent the last decade researching programming, how to learn and how to teach it.

Quotes
'Ah, that makes sense now!’ and ‘Oh, I hadn’t thought of that!' have been the background rhythm when reading this book. Thinking about thinking is addictive!
- Jon Skeet, Google

Helps you understand how your brain works and how you can use it more effectively to read, write, and collaborate on code.
- Ben McNamara, DataGeek

Teaches you science-based habits to reduce your mental workload and hack your way to becoming a rockstar programmer!
- Daniela Zapata Riesco, M1 Finance

If you’ve ever wondered what working smarter instead of harder is supposed to look like, you should read this book. I am already seeing improvements in my day-to-day work.
- Zhijun Liu, Mediaocean

A great book with deep insights into the bridge between programming and the human mind.
- Mike Taylor, CGI

Table of contents

  1. The Programmer's Brain
  2. Copyright
  3. contents
  4. front matter
    1. foreword
    2. preface
    3. acknowledgments
    4. about this book
    5. How this book is organized: A roadmap
    6. liveBook discussion forum
    7. about the author
    8. about the cover illustration
  5. Part 1. On reading code better
  6. 1 Decoding your confusion while coding
    1. 1.1 Different kinds of confusion in code
      1. 1.1.1 Confusion type 1: Lack of knowledge
      2. 1.1.2 Confusion type 2: Lack of information
      3. 1.1.3 Confusion type 3: Lack of processing power
    2. 1.2 Different cognitive processes that affect coding
      1. 1.2.1 LTM and programming
      2. 1.2.2 STM and programming
      3. 1.2.3 Working memory and programming
    3. 1.3 Cognitive processes in collaboration
      1. 1.3.1 A brief dissection of how the cognitive processes interacted
      2. 1.3.2 Cognitive processes regarding programming tasks
    4. Summary
  7. 2 Speed reading for code
    1. 2.1 Quickly reading code
      1. 2.1.1 What just happened in your brain?
      2. 2.1.2 Reexamine your reproduction
      3. 2.1.3 Reexamining your second attempt at reproducing code
      4. 2.1.4 Why is reading unfamiliar code hard?
    2. 2.2 Overcoming size limits in your memory
      1. 2.2.1 The power of chunking
      2. 2.2.2 Expert programmers can remember code better than beginners
    3. 2.3 You see more code than you can read
      1. 2.3.1 Iconic memory
      2. 2.3.2 It’s not what you remember; it’s the way you remember it
      3. 2.3.3 Practice chunking
    4. Summary
  8. 3 How to learn programming syntax quickly
    1. 3.1 Tips for remembering syntax
      1. 3.1.1 Disruptions play havoc with your workflow
    2. 3.2 How to learn syntax quickly with flashcards
      1. 3.2.1 When to use the flashcards
      2. 3.2.2 Expanding the set of flashcards
      3. 3.2.3 Thinning the set of flashcards
    3. 3.3 How to not forget things
      1. 3.3.1 Why do we forget memories?
      2. 3.3.2 Spaced repetition
    4. 3.4 How to remember syntax longer
      1. 3.4.1 Two forms of remembering information
      2. 3.4.2 Just seeing information is not enough
      3. 3.4.3 Remembering information strengthens memories
      4. 3.4.4 Strengthen memories by actively thinking
    5. Summary
  9. 4 How to read complex code
    1. 4.1 Why it’s hard to understand complex code
      1. 4.1.1 What’s the difference between working memory and STM?
      2. 4.1.2 Types of cognitive load as they relate to programming
    2. 4.2 Techniques to reduce cognitive load
      1. 4.2.1 Refactoring
      2. 4.2.2 Replacing unfamiliar language constructs
      3. 4.2.3 Code synonyms are great additions to a flashcard deck
    3. 4.3 Memory aids to use when your working memory is overloaded
      1. 4.3.1 Creating a dependency graph
      2. 4.3.2 Using a state table
      3. 4.3.3 Combining dependency graphs and state tables
    4. Summary
  10. Part 2. On thinking about code
  11. 5 Reaching a deeper understanding of code
    1. 5.1 Roles of variables framework
      1. 5.1.1 Different variables do different things
      2. 5.1.2 Eleven roles to cover almost all variables
    2. 5.2 Roles and paradigms
      1. 5.2.1 Benefits of roles
      2. 5.2.2 Hungarian notation
    3. 5.3 Gaining a deeper knowledge of programs
      1. 5.3.1 Text knowledge vs. plan knowledge
      2. 5.3.2 Different stages of program understanding
    4. 5.4 Reading text is similar to reading code
      1. 5.4.1 What happens in the brain when we read code?
      2. 5.4.2 If you can learn French, you can learn Python
    5. 5.5 Text comprehension strategies applied to code
      1. 5.5.1 Activating prior knowledge
      2. 5.5.2 Monitoring
      3. 5.5.3 Determining the importance of different lines of code
      4. 5.5.4 Inferring the meaning of variable names
      5. 5.5.5 Visualizing
      6. 5.5.6 Questioning
      7. 5.5.7 Summarizing code
    6. Summary
  12. 6 Getting better at solving programming problems
    1. 6.1 Using models to think about code
      1. 6.1.1 The benefits of using models
    2. 6.2 Mental models
      1. 6.2.1 Examining mental models in detail
      2. 6.2.2 Learning new mental models
      3. 6.2.3 How to use mental models efficiently when thinking about code
    3. 6.3 Notional machines
      1. 6.3.1 What is a notional machine?
      2. 6.3.2 Examples of notional machines
      3. 6.3.3 Different levels of notional machines
    4. 6.4 Notional machines and language
      1. 6.4.1 Expanding sets of notional machines
      2. 6.4.2 Different notional machines can create conflicting mental models
    5. 6.5 Notional machines and schemata
      1. 6.5.1 Why schemata matters
      2. 6.5.2 Are notional machines semantics?
    6. Summary
  13. 7 Misconceptions: Bugs in thinking
    1. 7.1 Why learning a second programming language is easier than learning the first one
      1. 7.1.1 How to increase the chances of benefiting from existing programming knowledge
      2. 7.1.2 Different forms of transfer
      3. 7.1.3 Already knowing something: Curse or blessing?
      4. 7.1.4 The difficulties of transfer
    2. 7.2 Misconceptions: Bugs in thinking
      1. 7.2.1 Debugging misconceptions with conceptual change
      2. 7.2.2 Suppressing misconceptions
      3. 7.2.3 Misconceptions about programming languages
      4. 7.2.4 Preventing misconceptions while learning a new programming language
      5. 7.2.5 Diagnosing misconceptions in a new codebase
    3. Summary
  14. Part 3. On writing better code
  15. 8 How to get better at naming things
    1. 8.1 Why naming matters
      1. 8.1.1 Why naming matters
      2. 8.1.2 Different perspectives on naming
      3. 8.1.3 Initial naming practices have a lasting impact
    2. 8.2 Cognitive aspects of naming
      1. 8.2.1 Formatting names supports your STM
      2. 8.2.2 Clear names help your LTM
      3. 8.2.3 Variable names can contain different types of information to help you understand them
      4. 8.2.4 When to evaluate the quality of names
    3. 8.3 What types of names are easier to understand?
      1. 8.3.1. To abbreviate or not to abbreviate?
      2. 8.3.2 Snake case or camel case?
    4. 8.4 The influence of names on bugs
      1. 8.4.1 Code with bad names has more bugs
    5. 8.5 How to choose better names
      1. 8.5.1 Name molds
      2. 8.5.2 Feitelson’s three-step model for better variable names
    6. Summary
  16. 9 Avoiding bad code and cognitive load: Two frameworks
    1. 9.1 Why code with code smells creates a lot of cognitive load
      1. 9.1.1 A brief intro to code smells
      2. 9.1.2 How code smells harm cognition
    2. 9.2 The influence of bad names on cognitive load
      1. 9.2.1 Linguistic antipatterns
      2. 9.2.2 Measuring cognitive load
      3. 9.2.3 Linguistic antipatterns and cognitive load
      4. 9.2.4 Why linguistic antipatterns cause confusion
    3. Summary
  17. 10 Getting better at solving complex problems
    1. 10.1 What is problem solving?
      1. 10.1.1 Elements of problem solving
      2. 10.1.2 State space
    2. 10.2 What is the role of the LTM when you solve programming problems?
      1. 10.2.1 Is problem solving a cognitive process on its own?
      2. 10.2.2 How to teach your LTM to solve problems
      3. 10.2.3 Two types of memories that play a role in problem solving
    3. 10.3 Automatization: Creating implicit memories
      1. 10.3.1 Implicit memories over time
      2. 10.3.2 Why automatization will make you program quicker
      3. 10.3.3 Improving implicit memories
    4. 10.4 Learning from code and its explanation
      1. 10.4.1 A new type of cognitive load: Germane load
      2. 10.4.2 Using worked examples in your working life
    5. Summary
  18. Part 4. On collaborating on code
  19. 11 The act of writing code
    1. 11.1 Different activities while programming
      1. 11.1.1 Searching
      2. 11.1.2 Comprehension
      3. 11.1.3 Transcription
      4. 11.1.4 Incrementation
      5. 11.1.5 Exploration
      6. 11.1.6 What about debugging?
    2. 11.2 Programmer interrupted
      1. 11.2.1 Programming tasks require a warm-up
      2. 11.2.2 What happens after an interruption?
      3. 11.2.3 How to better prepare for interruptions
      4. 11.2.4 When to interrupt a programmer
      5. 11.2.5 Some thoughts on multitasking
    3. Summary
  20. 12 Designing and improving larger systems
    1. 12.1 Examining the properties of codebases
      1. 12.1.1 Cognitive dimensions
      2. 12.1.2 Using CDCB to improve your codebase
      3. 12.1.3 Design maneuvers and their trade-offs
    2. 12.2 Dimensions and activities
      1. 12.2.1 Impact of dimensions on different activities
      2. 12.2.2 Optimizing your codebase for expected activities
    3. Summary
  21. 13 How to onboard new developers
    1. 13.1 Issues in the onboarding process
    2. 13.2 Differences between experts and novices
      1. 13.2.1 Beginners’ behavior in more depth
      2. 13.2.2 Difference between seeing concepts concretely and abstractly
    3. 13.3 Activities for a better onboarding process
      1. 13.3.1 Limit tasks to one programming activity
      2. 13.3.2 Support the memory of the onboardee
      3. 13.3.3 Read code together
    4. Summary
  22. epilogue
    1. Some words to close this book
  23. index

Product information

  • Title: The Programmer's Brain
  • Author(s): Felienne Hermans
  • Release date: September 2021
  • Publisher(s): Manning Publications
  • ISBN: 9781617298677