Chapter 4 of 10All chapters
Chapter 4 of 10
Following state
Where values come from and go.
Trace backwards
When a value is wrong, walk backwards from where it is used to where it was set. That is usually shorter than reading forwards from the start.
- Search for assignments to the name across the codebase.
- Watch for shared references: two names for one object is a classic surprise.
Mutation
Code that changes data in place is harder to follow than code that returns new values, because the meaning of a variable depends on when you look at it.