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