Chapter 7 of 10All chapters
Chapter 7 of 10
Using history
The code is a record of decisions.
Blame and log
git blame shows which commit last touched a line, and the message often explains the line that looks pointless. A strange condition usually has an incident behind it.
- Look at the whole commit, not just the line: context is in the neighbours.
- A line changed many times is a line people keep getting wrong.
Chesterton's fence
Before removing something you do not understand, find out why it was put there. Code that looks redundant is often load-bearing in a way nobody documented.