Taro Logo
3

What sort of code reading strategies do you use?

Profile picture
Senior Software Engineer [E4] at GitHuba year ago

Do you use some kind of "code reading" techniques? I've always felt the more senior you become, the more time you spend reading others' work, especially across multiple projects. Curious to know if there any recommendations on where to start, gathering context while staying productive.

185
2

Discussion

(2 comments)
  • 4
    Profile picture
    Staff SWE at Google, ex-Meta, ex-Amazon
    a year ago

    it depends. Is it for comprehension or for critique?

    if it’s for comprehension, i tend to work vertically. What makes field X display on screen, or sets a given field in an API request. Then work backwards to the source. I find that getting a broad understanding of a given subsystem is less helpful than seeing how the layers fit together at first.

    For reviews it’s honestly a lot more “code smell”. I’d there something odd about the shape of code? Something that seems totally against idiom or standards? I do look at context, but normally during the grokking process for an “interesting” bit.

  • 1
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero, PayPal
    a year ago

    I follow the tips across these resources:

    Paraphrasing the points from above:

    1. Find someone to give you a high-level overview of the codebase.
    2. Identify the 1-5 most impactful classes/modules and read those.
    3. Make changes to the code and add print statements everywhere. Then run it to see what happens. If you're working with front-end, you can just print messages directly to the UI (e.g. in Android, you can use the Toast library to spam debug info).
    4. Understand how to "command click" in your IDE, so you can easily follow call chains.