Hacker News new | ask | show | jobs
by corysama 3283 days ago
The way I make myself familiar with new code is to find some process of interest and write out a psuedo code stack trace from the trigger through execution. So, function names, relevant params, leave out error handling and irrelevant branches. If a step is async, reset indentation and annotate the "stack" with "and later..."

This process can collapse large amounts of code into a hopefully a single page of text that can be well understood. Without it, I find it very difficult to keep all of the relevant code in my head when it's spread across the code base.

1 comments

I like it! I'll have to try that the next time I encounter some new code.

A few questions:

* Do you worry about file names?

* Do you use names from the code or your own shorthand?

* How do you handle conditionals?

No filenames. Just functions. Collapsing info from multiple files is a big part of the goal. IDE search works well enough that I rarely know what file I'm in.

I use names from the code. I do want to be able to locate the code later.

I try to omit most conditionals. The goal is to show the path of interest, not all possible paths. Some conditionals are interesting though --very likely errors, process cancellations, scary bug-tempting edge cases.