3 ms·
I'm surprised I didn't see something similar to what I do: the deep-dive. I start with a relatively high level interface point, such as an important function i
by scott_s 12y ago
I'm surprised I didn't see something similar to what I do: the deep-dive.
I start with a relatively high level interface point, such as an important function in a public API. Such functions and methods tend to accomplish easily understandable things. And by "important" I mean something that is fundamental to what the system accomplishes.
Then you dive.
Your goal is to have a decent understanding of how this fundamental thing is accomplished. You start at the public facing function, then find the actual implementation of that function, and start reading code. If things make sense, you keep going. If you can't make sense of it, then you will probably need to start diving into related APIs and - most importantly - data structures.
This process will tend to have a point where you have dozens of files open, which have non-trivial relationships with each other, and they are a variety of interfaces and data structures. That's okay. You're just trying to get a feel for all of it; you're not necessarily going for total, complete understanding.
What you're going for is that Aha! moment where you can feel confident in saying, "Oh, that's how it's done." This will tend to happen once you find those fundamental data structures, and have finally pieced together some understanding of how they all fit together. Once you've had the Aha! moment, you can start to trace the results back out, to make sure that is how the thing is accomplished, or what is returned. I do this with all large codebases I encounter that I want to understand. It's quite fun to do this with the Linux source code.
My philosophy is that "It's all just code", which means that with enough patience, it's all understandable. Sometimes a good strategy is to just start diving into it.
- NotAtWork 12y agoYour strategy is similar to mine, except that I only focus on the types. Which types are required to define the function, both as parameters and through any global/inherited scope/other state? Which types are directly related, eg, containers to string, containers themselves, indexing, etc? By the time you have some sense of what things go where in the program, and what they turn in to, you usually have significantly narrowed down what the program can be doing. Note: This works considerably better with some languages than others, but can work reasonably well on weakly typed things like Python.
- scott_s 12y agoYou inevitably spend much of your time understanding the types and the concepts they represent, but I find using a specific, high-level function to drive the understanding helpful. One, it provides a "theme" for the deep-dive, and two, the logic of that functions gives you particular paths through those types to focus on.
- Bluestrike2 12y agoThis, more than anything. It's easy to get bogged down in a large code base and lose sight of what you're trying to accomplish. Cue the anxiety at that point, and watch your tasks become even more difficult. Your note that "it's all just code" is absolutely perfect: you just have to trust in your experience and knowledge. Figuring it all out from there is just a matter of tracing things out a point at a time. The really cool thing about that is that it's really no different than how we handle other new experiences in our lives. Nobody walks into something new and just knows what to do. Without even consciously realizing it, we make observations and draw inferences as we relate those observations to previous experience that allow us to make better-informed judgments. And thousands of years of evolution have made us rather good at this. You already have the skills to jump into the deep end without being immediately overwhelmed, it's just a matter of applying them successfully.