DEV Community

Cesar Aguirre
Cesar Aguirre

Posted on • Originally published at canro91.github.io

3 Code Reading Techniques No Course Will Teach You

I originally posted this post on my blog.


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.

These days, 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, I wanted every piece of code around me to be perfect.

No comments.
No booleans as parameters.
No more than 20 lines per function.

Every time 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

That's especially true 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.

Reading code has been one of the most effective ways to improve my coding skills. In fact, I believe it's the best way to learn to code. That's why I made it one of the 30 proven strategies in my book, Street-Smart Coding: 30 Ways to Get Better at Coding. That's the roadmap I wish I had when I was starting out.

Grab your copy of Street-Smart Coding here

Top comments (0)