Become A Better Programmer - How To Read Source Code
Reading soure code has many benefits. You will discover new constructs and libraries, develop empathy for others maintaining your code, and most importantly learn how to structure your code so that it doesn't fall over from internal complexity.
There is one drawback though, reading source code is darned hard. When I look at a new code base, this sickening feeling washes over me. My mind just doesn't want to dive into this perceived mess.
This is (hopefully) a normal response. When our brains sees too much novelty, it just tends to shy away. There is nothing for our amazing biological pattern matching machine to latch onto. The abstractions are all new. It's never seen the class names before. Where does execution even start?
The general tips I can offer are the following: 1. Find and establish an initial base for your mind to latch onto. Usually the main entry point. 2. Start from your base and explore the major features. 3. Take notes on what you've seen.
Start At The Beginning.
The trick is to give your mind a starting point. Here is what I do. I just run the program with the -h option and invoke the help. Then I copy one of the help strings and do a search over the code base to see where this help text is located. Usually the help invocation is pretty close to where the main entry point to the program is.
Read full article from Become A Better Programmer - How To Read Source Code
No comments:
Post a Comment