Ask HN: How do you read code?
1–10 of 12 posts
Re: Ask HN: How do you read code?
#2Re: Ask HN: How do you read code?
#3List 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 browse the code at deeper level, as if you were doing a code review. You can pretty much assume that, every couple lines, there is always something you would change about the code. Make a note of it.
At this point, you should have a fairly decent idea of how the code works, and how you would change it.
Re: Ask HN: How do you read code?
#4Re: Ask HN: How do you read code?
#5Re: Ask HN: How do you read code?
#6If 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…
Re: Ask HN: How do you read code?
#7Re: Ask HN: How do you read code?
#8If 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…
Re: Ask HN: How do you read code?
#9I look at what it does, do a quick architecture in my head, then compare it to what I see. This helps me because before I even look at it I have an understanding of how I think it should work rather than an absolutely clean slate.
Re: Ask HN: How do you read code?
#10Well you should always ask someone who has worked with it but lately I had to come up quickly with a phone formatter class. I didn't have a clue how it worked, no comments. So I start to rewrite some of it, run it see what happens. Then when I learned what the stuff did I renamed it so it made sense to me. Used real long variable names which were meaningfull not just tmp and temp. Can really recommend it and it was v…