0% found this document useful (0 votes)
16 views1 page

Programmers Brain

The document discusses cognitive processes involved in programming, focusing on memory types such as Short Term Memory (STM), Long Term Memory (LTM), and Working Memory (WM). It provides strategies for improving code reading and writing skills, emphasizing the importance of chunking information, spaced repetition, and clear naming conventions. Additionally, it highlights the similarities between reading code and natural language comprehension, and offers tips for effective onboarding and collaboration among developers.

Uploaded by

Edgar Valderrama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Programmers Brain

The document discusses cognitive processes involved in programming, focusing on memory types such as Short Term Memory (STM), Long Term Memory (LTM), and Working Memory (WM). It provides strategies for improving code reading and writing skills, emphasizing the importance of chunking information, spaced repetition, and clear naming conventions. Additionally, it highlights the similarities between reading code and natural language comprehension, and offers tips for effective onboarding and collaboration among developers.

Uploaded by

Edgar Valderrama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

THE PROGRAMMER'S BRAIN

by Felienne Hermans
60%
Short Term Memory (STM) Long Term Memory (LTM)
RAM or a cache of our brain Hard drive of our brain
Just a few items fit in STM (<12) Can store memories for a very long time
Code Store some of the info we encounter Retrieve related knowledge (ex : keywords)
of our time
Info traveling from the STM Combined with information from
into the working memory the LTM
Why is reading unfamiliar code hard?
Working Memory (WM)
code
Processor of our brain
ad Short term memory
we re The actual “thinking” happens here
When
Time : 30 seconds
Mentally execute the code aka TRACING Size : 7 +/-2 things

How to read code better ? "More concepts, data structures and syntax you know the more
code you can easily chunk, and thus remember and process"
Write CHUNKABLE
Code
Learn programming syntax “Experts group info in logical ways
Read a.k.a chunks”
/ Hid
e / W
code
Use Flashcards Remember syntax longer exer
cises
rite
Write COMMENTS
Front : prompt Retrieval : trying to remember something
High-level comments help to
Back : corresponding knowledge Elaboration : connecting new knowledge to existing memories chunk larger pieces of code

Use Design PATTERNS


How to not forget things ? "We cannot remember things for a long time without extra practice" Help to process code faster

Spaced repetition Revisit your Flashcards


After 2 days, just 25% of the
Practice regularly Once a month Leave BEACONS
knowledge remains in our LTM
Best way to prevent forgetting Each repetition strengthens your memory var names, operators (+, >),
if, else, comments,...

Read complex code easier


load "Our ability to learn a natural language can be a
itive Refactoring code
cogn predictor of your ability to learn to program."
Re duce Ex : replace unfamiliar language constructs

Dependency graph
State table Roles of variables
Circle variables
Focuses on the values of variables (Sajaniemi’s framework)
Draw lines between occurrences
1 column / variable
1 line / step in the code Fixed value : value does not change after initialization
Gatherer : collects data and aggregates it
Stepper : variable stepping through a list of values
Container : holds multiple elements
Flag : has happened or is the case
Follower : keep track of a previous value
Walker : traverses a data structure (search index)
Cognitive load Most-recent holder : holds the latest value encountered
Organizer : transformed variable
Temporary : used only briefly
Capacity of our Working Memory Most-wanted holder : holds the best value found so far

Capacity : 2 to 6 "things"
"Understanding what types of information variables hold is key to being able to
reason about and make changes to code."

"Many similarities between reading


code and reading natural language"
Text comprehension strategies applied to code
Activating
Actively thinking about code elements help our WM to find
relevant information stored in the LTM

Monitoring Determining importance


Identify which parts of the code are likely to have the most
Keep track of what we are reading and our understanding
influence on the program’s execution
ex : ticking the lines

Inferring Visualizing
Inferring the meaning of variable names List all operations in which variables are involved
Goal of the code: what is the code trying to achieve?
(dependency graph, state table,…)
Most important lines of code
Most relevant domain concepts
Most relevant programming constructs
Questioning …
Asking ourself questions while reading code Summarizing
Help us understand the code’s goals and functionality Write a summary of code in natural language
ex : What are the 5 most central concepts of the code? Help us gain a deeper understanding of what’s happening in that code

Write better code Avoid Arnaoudova’s linguistic anti-patterns


Abbreviation
Check Hofmeister research
Avoid
Methods that do more than they say Methods that say more than they do

Clear names help our LTM Snake Case -> use camel Case
Methods that do the opposite than Identifiers whose name says that they
camelCase leads to higher accuracy
LTM searches for related informations they say contain less than what the entity contains

Identifiers whose name says that they Identifiers whose name says the opposite
contain more than what the entity contains than the entity contains
LTM can store different types of memory

Memories Their occurrence in 7 open-source projects :


11% of setters also return a value
2.5% of methods : method name + comment = opposite descriptions
64% of identifiers starting with ‘is’ turned out not to be Boolean

Procedural / Implicit Declarative / Explicit "Experts heavily rely on episodic memory when solving
How to do something Memories we are explicitly aware of
problems / rely on solutions that have previously
ex : How to run a bike Facts we can remember
worked for similar problems."

Episodic Semantic
Memories of experience Memories for meanings / concepts / facts
ex : meeting our wife / husband ex : 10 x 10 = 100

Getting better at solving complex problems


Code reading club
Exchange code / explanation
Automatization "Set some time aside every day to practice and continue until you can Study worked examples Learn from each other
consistently perform the tasks without any effort"
create implicit memories create episodic memories
Read books / blog post
About source code
Deliberate practice to improve skills
Repeat a lot
It frees up cognitive load for larger problems Explore github
ex : deliberately type 100 for loops when struggling with it Choose repositories (domain knowledge)
Focus on the programming itself

Deliberate practice : requires focused attention and is Worked examples : something like a recipe which describes in detail
conducted with the specific goal of improving performance. the steps that are needed to solve the problem.

% of developers time 15' to start editing code


on interrupts
Better handle interruptions after an interruption

Prepare for it
Store mental model
Apart from the code
Help your "Prospective memory" Label subgoals
Comments : excellent location to leave it Put TODO comments in the part of the code Write down small steps of a problem
Warm-up period in comprehension activities Remind you to complete / improve part of the code Use mind maps for example

Prospective memory : memory of remembering to do something in


the future. (related to planning / problem solving)
On-boarding process
High cognitive
load Domain learning
Typical Explain only relevant
informations Separate
dev throws Exploring code
information

Support the LTM of the newcomer


Senior dev Newcomer

Searching
Exploration ex : find a class that implements a certain interface
Browse the codebase
Get a general sense of the codebase
Limit tasks to Comprehension
Understand aspects of the code
Transcription ONE programming activity ex : summarize a specific method in natural language
Give the newcomer a clear plan
Implement it
Incrementation
Add a feature to an existing class Start with it : read code together
Creation of the plan for the feature.

#sharingiscaring by Yoan THIRION @yot88

You might also like