Skip to content

Instantly share code, notes, and snippets.

@xavierchia
Last active June 26, 2020 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierchia/d0b894348d32762c7ab295958f931cc4 to your computer and use it in GitHub Desktop.
Save xavierchia/d0b894348d32762c7ab295958f931cc4 to your computer and use it in GitHub Desktop.

How to read source code

Why it’s important

  1. Most of your time will be spent reading, not writing.
  2. Simulates working at a company or open source project.
  3. It's the fastest way to learn and improve.
  4. Learn how to ignore large parts of a codebase and get a piece-by-piece understanding.

Before you start

  1. Read the docs (if they exist).
  2. Run the code.
  3. Play with the code to see how it behaves.
  4. Think about how the code might be implemented.
  5. Get the code into an editor so that you can modify it.
  6. Look at the file structure.

The process

  1. Get a sense for the overall structure
  2. Make note of any unfamiliar concepts that you might need to research later.
  3. Look at each function or snippet and see how they are connected without diving into concepts from #2.
  4. Test one feature with the debugger.
  5. Document and add comments to confusing areas.
  6. Research items in #2 only if required.
  7. Repeat steps 4-6 if you want to understand more.

Next level

  1. Replicate parts of the app by hand (in the console).
  2. Make small changes and see what happens.
  3. Add a new feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment