Live data from Hacker News

Ask HN: How do you read code?

news.ycombinator.com

11–12 of 12 posts

Re: Ask HN: How do you read code?

#11

if you have a good debugger then start at the beginning and run it line by line. if a section looks understandable skip it.

Thanks for your answer sharemywin! What if you were looking at a large project that doesn't have a well-defined "beginning?" How would you pick what code to run through the debugger first?

Re: Ask HN: How do you read code?

#12
post #8
post #3

If you have access to a whiteboard... List all of the directories (or classes, for a smaller project), and draw them as boxes on the board. Draw arrows between the boxes based on dependencies in the codebase (helps if you have someone already familiar). ... Now start at the bottom of the dependency graph, and browse the code at a medium level. If you are going to be working in this codebase, go back through and brows…

Thanks for the answer! It sounds like you're taking a bottom-up approach when reading code. Do you think we can use software to build this dependency graph and make it easier to read code?

Yes, technically it is possible. Some languages (and build tools) are a lot easier than others.

For purposes of learning the code, it may not be worth automating the dependency graph. You will probably learn more from tracking it down than you would if it was pre-generated for you.

Post reply on HN