Skip to product information
Programmer's Brain
Programmer's Brain
Description
Book Introduction
How to Improve Developers' Workflow Using Cognitive Science

This book uses various methodologies based on cognitive science to help developers quickly learn new languages ​​and frameworks and improve productivity.
Beyond better understanding your code, it presents scientifically proven techniques for bug prevention, clear naming, refactoring, and large-scale codebase improvement.
  • You can preview some of the book's contents.
    Preview

index
Translator's Preface xi
Recommendation xiii
Beta Reader Review xvi
Preface (John Skeet) xviii
Starting off xx
Acknowledgments xxii
About this book xxiv
About the cover xxvi

PART | Read Code Better

CHAPTER 1 Understanding Confusion While Coding 3
1.1 Three Types of Confusion Caused by Code 4
1.1.1 The First Type of Confusion: Lack of Knowledge 5
1.1.2 The Second Type of Confusion: Lack of Information 6
1.1.3 The Third Type of Confusion: Lack of Processing Capacity 6
1.2 Cognitive Processes that Affect Coding 7
1.2.1 LTM and Programming 8
1.2.2 STM and Programming 8
1.2.3 Working Memory Space and Programming 10
1.3 Interaction of Cognitive Processes 10
1.3.1 A brief description of how cognitive processes interact 10
1.3.2 Cognitive Processes Related to Programming Tasks 11
Summary 13

CHAPTER 2: Quick Code Analysis 14
2.1 Read the code quickly 15
2.1.1 What Happens in the Brain? 16
2.1.2 Revisiting the Reproduced Code 17
2.1.3 Revisiting the Second Experiment 19
2.1.4 Why is it difficult to read unfamiliar code? 19
2.2 Overcoming Memory Size Limitations 20
2.2.1 The Power of Unit Binding 20
2.2.2 Experts remember code better than beginners 23
2.3 Seeing is more than reading 25
2.3.1 Image memory space 25
2.3.2 It is not what you remember that is important, but how you remember it. 27
2.3.3 Chunking Exercise 33
Summary 35

CHAPTER 3: Learning Programming Grammar Quickly 36
3.1 Tips for Remembering Grammar 37
3.1.1 The negative effects of interruptions in the middle 37
3.2 Learning Grammar Using Flashcards 38
3.2.1 When to Use Flashcards 39
3.2.2 Flashcard Extension 39
3.2.3 Reduce the number of flashcards 40
3.3 How can I not forget? 40
3.3.1 Reasons for Losing Memory 41
3.3.2 Repeat at intervals 43
3.4 Remember grammar for longer 44
3.4.1 Two Forms of Remembering Information 44
3.4.2 Don't just look 45
3.4.3 Remembering information strengthens memory 46
3.4.4 Strengthening Memory through Active Thinking 47
Summary 50

CHAPTER 4 How to Read Complex Code 51
4.1 Why is it difficult to understand complex code? 52
4.1.1 Differences between working memory and STM 53
4.1.2 Types of Cognitive Load Related to Programming 53
4.2 Techniques for Reducing Cognitive Load 55
4.2.1 Refactoring 55
4.2.2 Replacing unfamiliar language components with others 57
4.2.3 Add code synonyms to flashcards 60
4.3 Memory aids that can be used when working memory space is stressed 61
4.3.1 Creating a Dependency Graph 61
4.3.2 Using State Tables 64
4.3.3 Mixing Dependency Graphs and State Tables 66
Summary 68

PART || Thinking about code

CHAPTER 5 Understanding Code Deeper 71
5.1 The 'Variable Role' Framework 72
5.1.1 Variables do different things 72
5.1.2 11 Roles 73
5.2 Roles and Paradigms 76
5.2.1 Role Benefits 76
5.2.2 Hungarian Notation 78
5.3 To get in-depth knowledge about the program, 80
5.3.1 Textual Knowledge vs. Planning Knowledge 80
5.3.2 Steps in Program Understanding 81
5.4 Reading text is similar to reading code 84
5.4.1 What Happens in Our Brains When We Read Code? 85
5.4.2 If You Can Learn French, You Can Learn Python 86
5.5 Text Comprehension Strategies You Can Apply to Reading Code 90
5.5.1 Activating Existing Knowledge 91
5.5.2 Monitoring 91
5.5.3 Determining Important Lines in Code 92
5.5.4 Inferring the meaning of variable names 93
5.5.5 Visualization 94
5.5.6 Ask a Question 96
5.5.7 Code Summary 96
Summary 97

CHAPTER 6: How to Get Better at Solving Coding Problems 98
6.1 Thinking about code using models 99
6.1.1 Benefits of the Model 99
6.2 Mental Models 102
6.2.1 A Closer Look at Mental Models 103
6.2.2 Learning a New Mental Model 104
6.2.3 How to Use Mental Models Effectively When Thinking About Code 105
6.3 Conceptual Machines 110
6.3.1 What is a conceptual machine? 111
6.3.2 Example of a Conceptual Machine 111
6.3.3 Layers of the Conceptual Machine 113
6.4 Conceptual Machines and Languages ​​114
6.4.1 Extension of the Conceptual Machine 114
6.4.2 Multiple conceptual machines can create conflicting mental models 115
6.5 Conceptual Machines and Schemata 117
6.5.1 Why are schemata important? 117
6.5.2 Is a Conceptual Machine Semantic? 117
Summary 117

CHAPTER 7: The Bug of Thought 119
7.1 Why is the second programming language easier than the first? 120
7.1.1 How to Increase the Likelihood of Leveraging Existing Programming Knowledge 122
7.1.2 Other Forms of Transition 123
7.1.3 Is Knowing Something a Curse or a Blessing? 124
7.1.4 Difficulties in Transition 125
7.2 Misconception: The Thinking Bug 127
7.2.1 Debugging Misconceptions Through Conceptual Change 128
7.2.2 Overcoming Misconceptions 129
7.2.3 Misconceptions about Programming Languages ​​130
7.2.4 Avoiding Misconceptions When Learning a New Programming Language 132
7.2.5 Diagnosing Misconceptions in a New Codebase 132
Summary 133

PART ||| Writing Good Code

CHAPTER 8 How to Naming Well 137
8.1 Why Names Matter 138
8.1.1 Why Naming Is Important 139
8.1.2 Various Perspectives on Naming 140
8.1.3 Early naming practices have lasting effects 142
8.2 Cognitive Aspects of Naming 144
8.2.1 Names with formats help STM 144
8.2.2 Clear names help LTM 145
8.2.3 Variable names can contain various types of information that aid understanding 146
8.2.4 When to Evaluate the Quality of Names 147
8.3 Which types of names are easier to understand? 148
8.3.1 To Abbreviate or Not to Abbreviate? 148
8.3.2 Snake Case or Camel Case? 152
8.4 How Names Affect Bugs 153
8.4.1 Code with bad names has more bugs 153
8.5 How to Choose a Better Name 154
8.5.1 Name Frame 154
8.5.2 Peitelson's Three-Step Model for Better Variable Names 157
Summary 158

CHAPTER 9 Two Frameworks to Prevent Bad Code and Cognitive Load 159
9.1 Why Code Smells Cause Cognitive Load 160
9.1.1 A Brief Introduction to Code Smells 160
9.1.2 How Code Smells Affect Cognitive Processes 163
9.2 The Effect of Bad Names on Cognitive Load 165
9.2.1 Linguistic Antipatterns 166
9.2.2 Cognitive Load Measurement 167
9.2.3 Linguistic Antipatterns and Cognitive Load 170
9.2.4 Why Linguistic Antipatterns Cause Confusion 171
Summary 172

CHAPTER 10: Getting Better at Solving Complex Problems 173
10.1 What is Problem Solving? 174
10.1.1 Troubleshooting Elements 174
10.1.2 State Space 174
10.2 What is the role of LTM in solving programming problems? 175
10.2.1 Is problem solving itself a cognitive process? 175
10.2.2 LTM Training Methods for Problem Solving 177
10.2.3 Two Types of Memory That Play a Role in Problem Solving 177
10.3 Automation: Creating Implicit Memories 180
10.3.1 Implicit Memory Over Time 181
10.3.2 Why Automation Can Make Programs Run Faster 184
10.3.3 Improving Implicit Memory 185
10.4 Learning from Code and Commentary 186
10.4.1 A New Type of Cognitive Load: Innate Load 187
10.4.2 Using Solved Examples in Development 189
Summary 190

PART |V Collaboration in Coding

CHAPTER 11 The Act of Writing Code 193
11.1 Various Activities During Programming 194
11.1.1 Search 194
11.1.2 Understanding 195
11.1.3 Warrior 195
11.1.4 Increased by 195
11.1.5 Exploration 196
11.1.6 What about debugging? 197
11.2 Programmer's Interruption 197
11.2.1 Warm-up required for programming tasks 198
11.2.2 What happens after a break? 198
11.2.3 How to Prepare for an Outage 199
11.2.4 When Interfering with the Programmer 202
11.2.5 Reflections on Multitasking 204
Summary 205

CHAPTER 12 Designing and Improving Large-Scale Systems 206
12.1 Investigating the Characteristics of the Codebase 207
12.1.1 Cognitive Dimension 207
12.1.2 Using CDCB to Improve the Codebase 217
12.1.3 Design Maneuvers and Tradeoffs 218
12.2 Dimensions and Activities 219
12.2.1 The Impact of Dimensions on Activity 219
12.2.2 Optimizing the Codebase for Expected Activity 221
Summary 221

CHAPTER 13 Onboarding New Developers 222
13.1 Problems with Adaptation Support 223
13.2 The Difference Between Experts and Beginners 224
13.2.1 Deeper Understanding of Beginner Behavior 225
13.2.2 The Difference Between Seeing a Concept Concretely and Abstractly 229
13.3 Improved Adaptation Support 231
13.3.1 Restrict a task to only one programming activity 231
13.3.2 Support for new team members' memories 232
13.3.3 Reading Code Together 234
Summary 237

In conclusion 238
Search 241

Detailed image
Detailed Image 1

Into the book
Lack of knowledge means that the content is not stored in the brain's long-term memory (LTM).
Long-term memory is where the information you remember is stored semi-permanently.
On the other hand, when there is a lack of information other than knowledge, it is because the corresponding content is not in the short-term memory (STM).
When we collect information, we temporarily store it in our short-term memory, but in the process of searching for other information, we forget some of the information we have already collected.
Finally, when we process a lot of information, it affects our working memory, which is the area we use when we think.

--- p.7

Studies show that nearly 60% of a programmer's time is spent "understanding" code, not "writing" it.
Therefore, if you can improve your ability to understand code quickly while maintaining accuracy, you will greatly improve your programming skills.
(…) When you first learn programming, you are very interested in creating code.
Whether in college, at work, or at a boot camp, once you learn programming, you'll spend a lot more time and attention on writing code.
We focus on training you on how to solve problems and implement them in code.
There will be little to no practice in reading code.
I hope this chapter will help you improve your code reading skills.

--- p.14~15

Panin recorded 10,000 programming sessions for 85 programmers.
He observed how often developers were interrupted by email or colleagues (which happened a lot!) and what happened afterward.
Panin concluded, unsurprisingly, that interruptions to work negatively impact productivity.
His research found that if you're interrupted while coding, it takes about 15 minutes to get back to the task.
Only about 10% of the time, the work was resumed within a minute after being interrupted during a method modification.
(…) Now let’s learn how to learn grammar quickly.
--- p.38

Computational ability, that is, knowledge and skills that require the application of mathematical ability, had little predictive power for programming ability.
There was only a 2% variance (deviation) among the experimental participants.
Language ability was found to be a better predictor, accounting for 17% of the variance.
This is an interesting result.
Developers usually value math skills, and many programmers I know have said they are not good at languages.
The factors that showed the greatest predictive power across the three tests were working memory capacity and reasoning ability.
--- p.87

Unfortunately, there is overwhelming evidence that people cannot multitask while engaging in deep cognitive tasks.
This might seem far-fetched, as some people might read this book while listening to music, or listen to it while running or knitting, so how can I assert that people can't do two things simultaneously? (...) Let's look at some scientific evidence that shows multitasking doesn't work as well as we think.
--- p.204

Publisher's Review
Know Your Brain, See Your Code: A Novel Way to Use Your Brain for Efficient Programming

Programming is a demanding cognitive activity.
You have to solve problems at an abstract level while also writing code.
By taking a scientific look at how our brain processes code, we can understand the causes of programming difficulties and find solutions.
This book covers how to fully utilize your brain to become a better programmer.
Understanding the mechanisms of the three cognitive activities—long-term memory, short-term memory, and working memory—will help you better understand and grasp the code.
Furthermore, it presents research results and scientifically proven techniques for everything from bug prevention and clear variable name selection to refactoring and large-scale codebase improvement, helping developers quickly learn new languages ​​and frameworks and increase productivity.
Juniors who struggle to learn new concepts can reduce unnecessary self-blame by learning that this is how their brains "just work."
Seniors who feel frustrated because the onboarding of new team members they selected for their experience is delayed will also realize that it is due to their brain and will be able to better understand their new team members.
Recommended for all readers who dream of becoming a better programmer.


Key Contents

■ How the brain works when recognizing code
■ Reading method to quickly understand code
■ Techniques for easily changing complex codes and problems
■ Tips for improving your codebase in a collaborative environment

Target audience

■ All developers who want to improve their programming skills
■ Junior developer who feels inferior because he or she is the only one who is not good at something
■ A senior developer frustrated with a junior who shows no progress no matter how much he teaches.
GOODS SPECIFICS
- Date of issue: January 12, 2022
- Page count, weight, size: 272 pages | 528g | 188*245*13mm
- ISBN13: 9791191600650
- ISBN10: 1191600653

You may also like

카테고리