Learning to read someone else's codebase without starting from line one

I opened an unfamiliar codebase and started reading files alphabetically. After an hour I understood individual functions but not how the application actually works. I'm thinking of tracing one user action from the entry point through the relevant modules and tests, then drawing a tiny map of the data flow. How do you orient yourself in someone else's project without needing to understand every file first?

  • programming-help
  • read
  • someone
  • else
30

5 replies · Sort: Best

Best
  1. CS
    charles_5
    4 points

    4 replies

    Your idea is good. I would start with one real user action, then follow the data from entry point to the first place it changes shape, becau...

    44 replies

    Your idea is good. I would start with one real user action, then follow the data from entry point to the first place it changes shape, because that's usually enough to get the architecture to stop feeling random.

    4
    1. BC
      benjamin.clark
      3 points

      Tracing one path is how I finally got unstuck on a project I inherited. Alphabetical reading gave me fragments, but a single request made the moving parts make sense.

      3

        Exactly. You do not need every file before you can understand the app, and trying to do that first is how I end up staring at utility code f...

      1. SO
        suzanne_55
        2 points

        Tests help too, if there are any good ones. I like to see what the code promises to do before I chase the implementation details.

        2

          That's a nice way to put it. The tests can tell you the intended story, while the files tell you how messy the story got.