Reading other people's code the way we read books
Programmers write every day and seldom read. I tried to put that right.

Writers are taught to read. Programmers, for some reason, are mostly taught to write. Six months ago I took up a habit: for half an hour a week I read the code of a project I use but do not contribute to.
Where to begin
Not with the first file in alphabetical order. I take one function that I call myself and follow it inwards: what it does first, where it hands work on, where it checks for errors. Tests often explain the intent better than the documentation.
What it gives me
I see how other people name things, divide code into parts and write comments. Some decisions I want to adopt. Others make sense only in the light of the change history, and then I read that.
Best of all, my fear of large projects has gone. Any codebase, if you follow a single thread, comes down to understandable steps.



Comments
No replies yet. Start the discussion.
Sign in to reply