I'm trying to understand how experienced people approach reading a codebase they didn't write, because I don't think I have a consistent method. I've done the "open random files until something looks familiar" thing more than once, and it doesn't scale.
These are the strategies I know about. I'd like to know which ones you really use, and in what order:
A. Run it and trace one request or one command. Pick a single user action, follow it from the entry point down to the database or output, and ignore everything else.
B. Read the tests. They show how the authors expect the code to be used — if there are any, and if they're good.
C. Read the history. git log on the files you'll touch, plus the commit messages and PRs around them, to find out why things are the way they are.
D. Read the docs and README first. Slower to start, but it can save time if they're accurate.
E. Ask someone. A short conversation with a person who knows the system, if there is one.
Specific questions:
- Is there an order you'd recommend, or does it depend on the project?
- What do you do when there are no tests, no docs and nobody to ask?
- How do you decide when you understand enough to start changing things?
- Is there something not on my list that you rely on — debugger, call-graph tools, drawing a diagram, writing notes as you go?
- What's a common mistake you see people make in their first days with a new codebase?
I'm interested in different kinds of environments (a small repo, a large legacy system, a company codebase vs an open source project), since I expect the answer differs. Thanks.