Taro Logo

What sort of code reading strategies do you use?

Profile picture
Senior Software Engineer [E4] at Github4 months 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.

3 Likes
132 Views
2 Comments
👑

Discussion

(2 comments)
  • Lee McKeeman
    Staff SWE at Google, ex-Meta, ex-Amazon
    4 months 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.

    3 Likes
  • Alex Chiou
    Tech Lead @ Robinhood, Meta, Course Hero, PayPal
    2 months 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.
    0 Likes