by minipci1321 · 9y ago · 0 comments
1. actually read the bloody code until you understand well what it does. Don't stop before that, or it won't count.
2. read as many different projects as you can -- different languages, technologies, paradigms, coding styles.
3. Don't spend time on code-comprehension tools, it won't work (speaking from personal experience. The latest was with "Understand C++" from SciTools, a great tool BTW). Master grep.
4. Drawing flowcharts, running under debugger, etc -- all that would be great but nobody allots time for that anymore (neither yourself nor your managers).
5. Don't hope for usable doc for external libraries. Exceptions exist, but it won't be a rule.
My brain will tune out whatever piece of code I've already read once. So if I initially skim some piece of code, figuring out what it -really- does is HARD.
Every subsequent look at that piece of code will be colored by my initial (mis)understanding of how it works
This trick is also useful proofreading documents you've read many times already.
Then after some time when I look at it again, I notice that actually I missed a step in that method which actually did contain the problem, which I did not see by skimming over the piece of code earlier.
4.) I only had to resort to flow charts a couple times so far, mostly with Java libraries to externalize the data and control flow, because it grew just waaayy to large to keep in my head. A particular vivid memory I have here is netty (which also has a tendency for a particularly convoluted and complex control flow realized through modifying pipelines conditionally in many places).
Especially because ag tends to be smart about what it will ignore (e.g., the contents of node_modules, etc.)
I've been chided for not doing this in the past (I just read the code usually) and would actually agree with that person in retrospect.
More generally, studying the code under debugger means you need particular input data -- the one suitable for the part of the code you study. That can take time to get.
Since most of the code I read (C# code) can be ran on my platform, I'll sometimes run into that rare piece of code that I can't believe it does what it says it does, in those cases I'll download the repo and debug it and many times be surprised to find there was a gap in my understanding. Reading code helps me find knowledge gaps I didn't even know were there.
Seems weird to say a team was always hung up on ensuring the correctness of their code. I guess it depends on what you work on to an extent.