Three Tips to Read Code More Effectively

We spend more time reading than writing code, but we’re seldom taught how to read it.

Almost 100% of my coding courses in university were about writing code: syntax, algorithms, and class design. Nothing about reading. I only learned about reading code from a coworker at a past job.

Yesterday, I found this conversation as part of the GOTO Conference about reading code:

Here are some key points from that conversation:

#1. Read a piece of code at first glance and see what stands out. Maybe that’s a function or a symbol or a messy block of code. That’s also my go-to guide to refactor a piece of code: while scrolling through a piece of code, if I need to stop and read it twice, there’s something to refactor, something needs to be better explained.

#2. Read with empathy. After reading Clean Code for the first time, when I found a piece of code that wasn’t closely aligned to the book, I always said “who wrote this crap?!” I had to learn that we all do our best with the context and deadlines we have. If we have to fix a pressing issue in 24 hours, we do our best. That might not be the perfect solution. And of course, there will always be better ways to solve a problem, once we solve it for the first time.

#3. Always start by pointing the good parts, especially when auditing or reviewing other people’s code. It reminds me of the principle from How to Win Friends and Influence People: don’t tell anyone they’re wrong.

Read more code, that’s the best way to learn to code. The more code you read, the better at writing you become.