I'm new to reading other people's code and finding the Scratch VM difficult to follow. Functions seem to be spread across files and imported from elsewhere. Where should I start?
How do you make sense of a large professional codebase?
Answers
Pick one small behavior rather than trying to understand the whole project. For example, choose a Scratch block and search for its name or behavior. Follow the relevant calls until you can explain how that one action gets handled.
Keep notes about the files you visit and draw a rough map of how they connect. You don't need to understand every helper function on the first pass.
Reply to this answer
Follow the data first. What goes into a function, what comes out, and where does it go next? You can skip over the details of a helper for a while if you understand its role in that path.
Try explaining the flow out loud or sketching it. Gaps in the explanation will give you a concrete next thing to investigate.
Reply to this answer
Check what language and version of the project you're looking at before deciding what those files mean. Different languages organize declarations and implementations differently.
For example, C header files often declare functions that are defined in a separate C source file. JavaScript uses its own module system, so look up the import or require syntax in the language documentation rather than assuming the same pattern applies.
Reply to this answer
Give yourself permission to look things up constantly. Language syntax, standard library functions, unfamiliar packages, all of it. Keep the relevant documentation open and compare small pieces of code against it as you read.
Reply to this answer
Don't use understanding the entire VM as your first benchmark. A large project has many subsystems, and virtual machines can be abstract even for experienced programmers. Getting a rough directory-level map first, then understanding one narrow path, is real progress.
Reply to this answer
Add your answer
Answers are reviewed before publication.
4s+opmarker_726:
It can also help to start with an entry point and trace one argument through the functions that use it. Search for the argument or function name when you lose the trail.