Techniques to scrutinize a complex code source.

Started by
1 comment, last by trojanman 16 years, 9 months ago
I was wondering what the procedures to interpret a lengthy code source are? Well you know, reading 1-2 page is quite simple, but I once there are more of 5 pages I’m starting to panic a little and I feel dizzy with the code lines. So I can’t imagine myself to work on a code source with more than 100 pages yet… I guess it’s simply because I ignore the reading technique. So, how you guys do it? Any website could guide me on the subjec? Thanks!
Advertisement
Don't spend too much time looking at the trees. You won't see the forest.

Code also isn't organized in pages, so it doesn't help to think about it in that way. It's also not a book with beginning and an end.

Figure out what you want to know. Then find a reference point, something where you can start from. Follow the logic from there.

Reading the code can also be completely unproductive unless you're familiar with design concepts. Seeing a a pattern and recognizing it as, say, inversion of control, will immediately reveal all the relations between classes.

Drawing flow diagrams is also helpful for some situations.

Modern IDEs also allow quick traversal between classes and methods, making it easy to follow the execution.

But above all - don't read the code. Use it, change it, add features, fix bugs. Reading it is as productive as reading a phone book. You won't learn anything useful, or understand it, unless you understand the design used.
Does the code have context or a path you can follow? Its very difficult to just understand code when there is no logic behind it. When trying to digest large amounts of source code I generally try to follow a path and then look through the code to find any unclear points.

For example, if I was given a large project to take and I needed to digest it I would start at the entry point (main, startapp, etc.) and follow the execution path to figure out what the code does.

This topic is closed to new replies.

Advertisement